Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Use updated account to compare and fix test descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Incede committed Oct 11, 2022
1 parent fd7980b commit 348102c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions framework/src/modules/token/cc_method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ export class TokenInteroperableMethod extends BaseInteroperableMethod {
crossChainForwardMessageParams,
ccm.params,
);
if (escrowAccount.amount < decodedParams.amount) {
const updatedEscrowAccount = await escrowStore.get(methodContext, escrowKey);
if (updatedEscrowAccount.amount < decodedParams.amount) {
this.events.get(BeforeCCMForwardingEvent).error(
methodContext,
{
Expand All @@ -163,7 +164,6 @@ export class TokenInteroperableMethod extends BaseInteroperableMethod {
throw new Error('Insufficient balance in the sending chain for the transfer.');
}

const updatedEscrowAccount = await escrowStore.getOrDefault(methodContext, escrowKey);
updatedEscrowAccount.amount -= decodedParams.amount;
await escrowStore.set(methodContext, escrowKey, updatedEscrowAccount);

Expand Down
6 changes: 3 additions & 3 deletions framework/test/unit/modules/token/cc_method.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ describe('TokenInteroperableMethod', () => {
);
});

it('should deduct escrow account for fee and credit to sender if ccm command is forward', async () => {
it('should deduct escrow account for fee and credit to receving chain escrow account if ccm command is forward', async () => {
await expect(
tokenInteropMethod.beforeCrossChainMessageForwarding({
ccm: {
Expand Down Expand Up @@ -356,7 +356,7 @@ describe('TokenInteroperableMethod', () => {
);
});

it('should deduct escrow account for fee+ccm.params.amount and credit to sender if ccm command is forward', async () => {
it('should deduct escrow account for fee+ccm.params.amount and credit to sender if ccm command is transfer', async () => {
await expect(
tokenInteropMethod.beforeCrossChainMessageForwarding({
ccm: {
Expand Down Expand Up @@ -428,7 +428,7 @@ describe('TokenInteroperableMethod', () => {
).resolves.toBeUndefined();
});

it('should reject if token id is native and fee payer does not have sufficient balance', async () => {
it('should reject if token id is native and sending chain escrow account does not have sufficient balance', async () => {
await expect(
tokenInteropMethod.verifyCrossChainMessage({
ccm: {
Expand Down

0 comments on commit 348102c

Please sign in to comment.