From f421a923028996eb43f5900e655dcd31cfb8647c Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Wed, 1 May 2024 18:27:37 -0500 Subject: [PATCH] WIP: more testing details --- .../test/test-withdraw-reward.js | 50 ++++++++++++++++--- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/packages/orchestration/test/test-withdraw-reward.js b/packages/orchestration/test/test-withdraw-reward.js index 155e1aa9d137..0cf28a829323 100644 --- a/packages/orchestration/test/test-withdraw-reward.js +++ b/packages/orchestration/test/test-withdraw-reward.js @@ -32,7 +32,7 @@ const scenario1 = { }, validator: { address: 'agoric1valoper234', addressEncoding: 'bech32' }, delegations: { - agoric1valoper234: { denom: 'ustake', amount: '200' }, + agoric1valoper234: { denom: 'uatom', amount: '200' }, }, }; @@ -106,8 +106,8 @@ test('MsgWithdrawDelegatorRewardResponse encoding', t => { t.is(typeof ackStr, 'string'); t.is( ackStr, - 'ElIKPy9jb3Ntb3MuZGlzdHJpYnV0aW9uLnYxYmV0YTEuTXNnV2l0aGR' + - 'yYXdEZWxlZ2F0b3JSZXdhcmRSZXNwb25zZRIPCg0KBnVzdGFrZRIDMjAw', + 'ElEKPy9jb3Ntb3MuZGlzdHJpYnV0aW9uLnYxYmV0YTEuTXNnV2l0aGRy' + + 'YXdEZWxlZ2F0b3JSZXdhcmRSZXNwb25zZRIOCgwKBXVhdG9tEgMyMDA=', ); }); @@ -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 => { @@ -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, @@ -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');