-
Notifications
You must be signed in to change notification settings - Fork 6
/
exit-reclaim.test.js
38 lines (30 loc) · 1.13 KB
/
exit-reclaim.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import test from 'ava';
import { $ } from 'execa';
import { execFileSync } from 'node:child_process';
import { makeAgd, waitForBlock } from '@agoric/synthetic-chain';
const offerId = 'bad-invitation-15'; // cf. prepare.sh
const from = 'gov1';
test('exitOffer tool reclaims stuck payment', async t => {
const showAndExec = (file, args, opts) => {
console.log('$', file, ...args);
return execFileSync(file, args, opts);
};
// @ts-expect-error string is not assignable to Buffer
const agd = makeAgd({ execFileSync: showAndExec }).withOpts({
keyringBackend: 'test',
});
const addr = await agd.lookup(from);
t.log(from, 'addr', addr);
const getBalance = async target => {
const { balances } = await agd.query(['bank', 'balances', addr]);
const { amount } = balances.find(({ denom }) => denom === target);
return Number(amount);
};
const before = await getBalance('uist');
t.log('uist balance before:', before);
await $`node ./exitOffer.js --id ${offerId} --from ${from}`;
await waitForBlock(2);
const after = await getBalance('uist');
t.log('uist balance after:', after);
t.true(after > before);
});