diff --git a/test/12.staking_tx.test.ts b/test/12.staking_tx.test.ts index 53381ce..deccb57 100644 --- a/test/12.staking_tx.test.ts +++ b/test/12.staking_tx.test.ts @@ -8,10 +8,10 @@ describe('[12. Staking Tx Test]', () => { it('delegate OK', async () => { - const wallet = await firma.Wallet.fromMnemonic(aliceMnemonic); + const wallet = await firma.Wallet.fromMnemonic(bobMnemonic); const validatorList = await firma.Staking.getValidatorList(); const validatorAddress = validatorList[0].operator_address; - + const amountFCT = 60; var result = await firma.Staking.delegate(wallet, validatorAddress, amountFCT); @@ -22,11 +22,11 @@ describe('[12. Staking Tx Test]', () => { it('undelegate OK', async () => { - const wallet = await firma.Wallet.fromMnemonic(aliceMnemonic); + const wallet = await firma.Wallet.fromMnemonic(bobMnemonic); const validatorList = await firma.Staking.getValidatorList(); const validatorAddress = validatorList[0].operator_address; - const amount = 1; + const amount = 5; // if there's 7 more list on undelegatelist, occur error below // too many unbonding delegation entries for (delegator, validator) tuple @@ -35,7 +35,7 @@ describe('[12. Staking Tx Test]', () => { expect(result.code).to.equal(0); }); - it.skip('redelegate OK', async () => { + it('redelegate OK', async () => { //INFO: need two validators but starport serve support only one validator. @@ -46,7 +46,7 @@ describe('[12. Staking Tx Test]', () => { const srcValidatorAddress = validatorList[0].operator_address; const dstValidatorAddress = validatorList[1].operator_address; - const amount = 1; + const amount = 10; let result = await firma.Staking.delegate(wallet, srcValidatorAddress, amount); expect(result.code).to.equal(0); @@ -55,24 +55,24 @@ describe('[12. Staking Tx Test]', () => { let result1 = await firma.Staking.redelegate(wallet, srcValidatorAddress, dstValidatorAddress, amount, { gas: 300000, fee: 3000 }); - expect(result1.code).to.equal(0); + expect(result1.code).to.equal(0); }); // new case added. if succeed, the dapp needs to prevent zero amount input from users. it('staking send Fail - send zero money', async () => { const wallet = await firma.Wallet.fromMnemonic(aliceMnemonic); - + const validatorList = await firma.Staking.getValidatorList(); const validatorAddress = validatorList[0].operator_address; const amount = 0; - try{ + try { var result = await firma.Staking.delegate(wallet, validatorAddress, amount); } - catch(error){ - + catch (error) { + } //expect(result.code).to.equal(5); @@ -82,7 +82,7 @@ describe('[12. Staking Tx Test]', () => { it('staking send Fail - send lots of money', async () => { const wallet = await firma.Wallet.fromMnemonic(aliceMnemonic); - + const validatorList = await firma.Staking.getValidatorList(); const validatorAddress = validatorList[0].operator_address; @@ -98,7 +98,7 @@ describe('[12. Staking Tx Test]', () => { it.skip('editValidator OK', async () => { const wallet = await firma.Wallet.fromMnemonic(validatorMnemonic); - + const validatorList = await firma.Staking.getValidatorList(); const validatorAddress = validatorList[0].operator_address; diff --git a/test/13.staking_query.test.ts b/test/13.staking_query.test.ts index 0d1bb8d..4a3ee21 100644 --- a/test/13.staking_query.test.ts +++ b/test/13.staking_query.test.ts @@ -6,47 +6,52 @@ describe('[13. Staking Query Test]', () => { const firma = new FirmaSDK(TestChainConfig); - it('get validator list', async () => { + it('1.get total validator list', async () => { var result = await firma.Staking.getValidatorList(); - expect(result.length).to.above(0); + //console.log(result); + }) - //console.log(result[0].grantee); - //console.log("total: " + result.length); - //console.log("commission_rates.max_rate:" + result[0].commission.commission_rates.max_rate); + it('2.get validator data', async () => { + + var validatorList = await firma.Staking.getValidatorList(); + var result = await firma.Staking.getValidator(validatorList[0].operator_address); + //console.log(result); }) - it('get pool', async () => { + it('3.get getDelegationListFromValidator', async () => { - var result = await firma.Staking.getPool(); - //console.log(result.bonded_tokens); - //console.log(result.not_bonded_tokens); + var validatorList = await firma.Staking.getValidatorList(); + var result = await firma.Staking.getDelegationListFromValidator(validatorList[1].operator_address); + //console.log(result); }) - it('get getParams', async () => { + it('4.get getUndelegationListFromValidator', async () => { + + var validatorList = await firma.Staking.getValidatorList(); + var result = await firma.Staking.getUndelegationListFromValidator(validatorList[0].operator_address); - var result = await firma.Staking.getParams(); //console.log(result); }) - // [TODO: need to implement] - // get delegation list based validator side - // not give total delegations, but give each user amount list. - it.skip('get getTotalDelegationFromValidator', async () => { + // param side + it('5.get staking total pool', async () => { - // [CHECK] - // I'm confusing of modify return type of cosmos sdk rest api - // Too complicated. I'm still thinking about it. + var result = await firma.Staking.getPool(); - //const wallet = await firma.Wallet.fromMnemonic(aliceMnemonic); - //var result = await firma.Staking.getTotalDelegationInfo(await wallet.getAddress()); + // bonded_token, not_bonded_tokens + //console.log(result); + }) + + it('6.get getParams', async () => { + + var result = await firma.Staking.getParams(); //console.log(result); }) - - // Receive a list of supplies delegated by the user. - it('get getTotalDelegationInfo', async () => { + // user side + it('7.get userside getTotalDelegationInfo', async () => { const wallet = await firma.Wallet.fromMnemonic(aliceMnemonic); var result = await firma.Staking.getTotalDelegationInfo(await wallet.getAddress()); @@ -54,22 +59,19 @@ describe('[13. Staking Query Test]', () => { //console.log(result); }) - it('get getTotalRedelegationInfo', async () => { + it('8.get userside getTotalRedelegationInfo', async () => { const wallet = await firma.Wallet.fromMnemonic(aliceMnemonic); var result = await firma.Staking.getTotalRedelegationInfo(await wallet.getAddress()); //console.log(result); - //console.log(result[0].entries[0].redelegation_entry.creation_height); - //console.log(result[0].entries[0]); }) - it('get getTotalUnbondingInfo', async () => { + it('9.get userside getTotalUndelegateInfo', async () => { const wallet = await firma.Wallet.fromMnemonic(aliceMnemonic); - var result = await firma.Staking.getTotalUnbondingInfo(await wallet.getAddress()); + var result = await firma.Staking.getTotalUndelegateInfo(await wallet.getAddress()); //console.log(result); - //console.log(result[0].entries[0]); }) }); \ No newline at end of file