Skip to content

Deny spending currencies absent from a lease budget #30

@nficano

Description

@nficano

Arcp::Runtime::LeaseManager#try_spend! currently treats a missing currency as unlimited spend. At lib/arcp/runtime/lease_manager.rb:64, the method returns true whenever the counter has no key for the requested currency and the synthetic remaining amount is zero. That contradicts the nearby comment that BudgetExhausted should be raised when no balance covers the amount, and it allows a job with a budget such as USD:1.00 to spend any amount in EUR or another unlisted currency without decrementing any counter.

Fix prompt: Remove the missing-currency success path and make try_spend! raise Arcp::Errors::BudgetExhausted when the job has a budget counter but the requested currency is absent or has insufficient balance. Preserve the intended behavior for jobs with no lease or no budget at all if unbudgeted jobs are meant to be unrestricted. Add tests for spending an unlisted currency, spending exactly the remaining amount, spending after exhaustion, and spending when no budget exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingseverity:highHigh severity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions