Msg/SealBatch
An open credit batch can be sealed:
- message validations
- when the credit batch exists
- when the issuer is the issuer of the credit batch
Message validation
a valid message
Given the message
{
"issuer": "regen1depk54cuajgkzea6zpgkq36tnjwdzv4ak663u6",
"batch_denom": "C01-001-20200101-20210101-001"
}
When the message is validated
Then expect no error.
an error is returned if batch denom is empty
Given the message
{
"issuer": "regen1depk54cuajgkzea6zpgkq36tnjwdzv4ak663u6"
}
When the message is validated
Then expect the error "batch denom: empty string is not allowed: parse error: invalid request".
an error is returned if batch denom is not formatted
Given the message
{
"issuer": "regen1depk54cuajgkzea6zpgkq36tnjwdzv4ak663u6",
"batch_denom": "foo"
}
When the message is validated
Then expect the error "batch denom: expected format [project-id]-<start_date>-<end_date>-<batch_sequence>: parse error: invalid request".
The credit batch must exist
Background
Given a credit type with abbreviation "C"
And a credit class with id "C01" and issuer alice
And a project with id "C01-001"
And a credit batch with denom "C01-001-20200101-20210101-001" and issuer alice.
the credit batch exists
When alice attempts to seal batch with denom "C01-001-20200101-20210101-001"
Then expect no error.
the credit batch does not exist
When alice attempts to seal batch with denom "C01-001-20200101-20210101-002"
Then expect the error "could not get batch with denom C01-001-20200101-20210101-002: not found: invalid request".
The issuer must be the issuer of the credit batch
Background
Given a credit type with abbreviation "C"
And a credit class with id "C01" and issuer alice
And a project with id "C01-001"
And a credit batch with denom "C01-001-20200101-20210101-001" and issuer alice.
the issuer is not the credit batch issuer
When alice attempts to seal batch with denom "C01-001-20200101-20210101-001"
Then expect no error.
the issuer is the credit batch issuer
When bob attempts to seal batch with denom "C01-001-20200101-20210101-001"
Then expect the error "only the batch issuer can seal the batch: unauthorized".
Event is emitted
Background
Given a credit type with abbreviation "C"
And a credit class with id "C01" and issuer alice
And a project with id "C01-001"
And a credit batch with denom "C01-001-20200101-20210101-001" and issuer alice.
EventSealBatch is emitted
When alice attempts to seal batch with denom "C01-001-20200101-20210101-001"
Then expect event with properties
{
"batch_denom": "C01-001-20200101-20210101-001"
}