Skip to content

Commit

Permalink
WIP: more testing details
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed May 1, 2024
1 parent ac4df0c commit f421a92
Showing 1 changed file with 42 additions and 8 deletions.
50 changes: 42 additions & 8 deletions packages/orchestration/test/test-withdraw-reward.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const scenario1 = {
},
validator: { address: 'agoric1valoper234', addressEncoding: 'bech32' },
delegations: {
agoric1valoper234: { denom: 'ustake', amount: '200' },
agoric1valoper234: { denom: 'uatom', amount: '200' },
},
};

Expand Down Expand Up @@ -106,8 +106,8 @@ test('MsgWithdrawDelegatorRewardResponse encoding', t => {
t.is(typeof ackStr, 'string');
t.is(
ackStr,
'ElIKPy9jb3Ntb3MuZGlzdHJpYnV0aW9uLnYxYmV0YTEuTXNnV2l0aGR' +
'yYXdEZWxlZ2F0b3JSZXdhcmRSZXNwb25zZRIPCg0KBnVzdGFrZRIDMjAw',
'ElEKPy9jb3Ntb3MuZGlzdHJpYnV0aW9uLnYxYmV0YTEuTXNnV2l0aGRy' +
'YXdEZWxlZ2F0b3JSZXdhcmRSZXNwb25zZRIOCgwKBXVhdG9tEgMyMDA=',
);
});

Expand Down Expand Up @@ -241,7 +241,7 @@ test('withdraw rewards from staking account holder', async t => {
const { helper } = make(account, storageNode, account.getAccountAddress());
const { validator } = scenario1;
const actual = await E(helper).withdrawReward(validator);
t.deepEqual(actual, [{ denom: 'ustake', value: 2n }]);
t.deepEqual(actual, [{ denom: 'uatom', value: 2n }]);
});

test(`delegate; withdraw rewards`, async t => {
Expand All @@ -255,9 +255,10 @@ test(`delegate; withdraw rewards`, async t => {
account.getAccountAddress(),
);

const { validator } = scenario1;
const { validator, delegations } = scenario1;
{
const anAmount = { brand: Far('Token'), value: 2n };
const value = BigInt(Object.values(delegations)[0].amount);
const anAmount = { brand: Far('Token'), value };
const toDelegate = await E(invitationMakers).Delegate(
validator.address,
anAmount,
Expand All @@ -275,10 +276,43 @@ test(`delegate; withdraw rewards`, async t => {
const seat = E(zoe).offer(toWithdraw);
const result = await E(seat).getOfferResult();

t.deepEqual(result, [{ denom: 'ustake', value: 2n }]);
t.deepEqual(result, [{ denom: 'uatom', value: 2n }]);
}
});

test.todo(`delegate; undelegate; collect rewards`);
test(`WIP delegate; undelegate; collect rewards`, async t => {
const { account, baggage, makeRecorderKit, storageNode, zcf, zoe } =
makeScenario();
const make = prepareStakingAccountKit(baggage, makeRecorderKit, zcf);

const { invitationMakers } = make(
account,
storageNode,
account.getAccountAddress(),
);

const { validator } = scenario1;
{
const anAmount = { brand: Far('Token'), value: 200n };
const toDelegate = await E(invitationMakers).Delegate(
validator.address,
anAmount,
);
const seat = E(zoe).offer(toDelegate);
const result = await E(seat).getOfferResult();

t.deepEqual(result, {});
}

{
const toWithdraw = await E(invitationMakers).WithdrawReward(
validator.address,
);
const seat = E(zoe).offer(toWithdraw);
const result = await E(seat).getOfferResult();

t.deepEqual(result, [{ denom: 'uatom', value: 2n }]);
}
});
test.todo('undelegate uses a timer: begin; how long? wait; resolve');
test.todo('undelegate is cancellable - cosmos cancelUnbonding');

0 comments on commit f421a92

Please sign in to comment.