Skip to content

Commit

Permalink
check expected vs observed payouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin Kennedy committed Aug 29, 2023
1 parent 09925d1 commit eeb259f
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions nitro-protocol/test/contracts/MultiAssetHolder/transfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ import {TESTNitroAdjudicator} from '../../../typechain-types/TESTNitroAdjudicato
import TESTNitroAdjudicatorArtifact from '../../../artifacts/contracts/test/TESTNitroAdjudicator.sol/TESTNitroAdjudicator.json';
import {channelDataToStatus} from '../../../src';
import {MAGIC_ADDRESS_INDICATING_ETH} from '../../../src/transactions';
import {replaceAddressesAndBigNumberify} from '../../../src/helpers';
import {replaceAddressesAndBigNumberify, isExternal} from '../../../src/helpers';

const testProvider = getTestProvider();

const testNitroAdjudicator = setupContract(
getTestProvider(),
testProvider,
TESTNitroAdjudicatorArtifact,
process.env.TEST_NITRO_ADJUDICATOR_ADDRESS
) as unknown as TESTNitroAdjudicator & Contract;
Expand Down Expand Up @@ -196,6 +198,23 @@ describe('transfer', () => {
];

expect(eventsFromTx).toMatchObject(expectedEvents);

// Check payouts
for (const destination of Object.keys(payouts)) {
if (isExternal(destination)) {
const asAddress = '0x' + destination.substring(26);
const balance = await testProvider.getBalance(asAddress);
console.log(`checking balance of ${destination}: ${balance.toString()}`);
expect(balance).toEqual(payouts[destination]);
} else {
const holdings = await testNitroAdjudicator.holdings(
MAGIC_ADDRESS_INDICATING_ETH,
destination
);
console.log(`checking holdings of ${destination}: ${holdings.toString()}`);
expect(holdings).toEqual(payouts[destination]);
}
}
}
}
);
Expand Down

0 comments on commit eeb259f

Please sign in to comment.