From 26e07719f6de0374815bedc12b3ef79e791e5f70 Mon Sep 17 00:00:00 2001 From: nhpd Date: Fri, 2 Aug 2024 03:06:13 +0400 Subject: [PATCH 1/2] burn different --- .../run_in_band/tokenfactory.test.ts | 51 +++++++++++++++++-- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/src/testcases/run_in_band/tokenfactory.test.ts b/src/testcases/run_in_band/tokenfactory.test.ts index 1863a613..c4750e5b 100644 --- a/src/testcases/run_in_band/tokenfactory.test.ts +++ b/src/testcases/run_in_band/tokenfactory.test.ts @@ -445,6 +445,8 @@ describe('Neutron / Tokenfactory', () => { ); expect(burnRes.code).toBe(0); + // TODO: test burn from different address? + const balanceAfter = parseInt( (await neutronClient.getBalance(neutronWallet.address, newTokenDenom)) .amount, @@ -660,11 +662,7 @@ describe('Neutron / Tokenfactory', () => { codeId = await neutronClient.upload(CONTRACTS.TOKENFACTORY); expect(codeId).toBeGreaterThan(0); - contractAddress = await neutronClient.instantiate( - codeId, - {}, - 'tokenfactory', - ); + contractAddress = await neutronClient.instantiate(codeId, {}); await neutronClient.sendTokens( contractAddress, @@ -753,6 +751,49 @@ describe('Neutron / Tokenfactory', () => { expect(balance).toEqual(amount); }); + test('burn coins from different wallet', async () => { + const wallet2 = await testState.nextWallet('neutron'); + + const mintedToDifferentWallet = 100; + const toBurn = 50; + const leftAfterBurn = mintedToDifferentWallet - toBurn; + + amount -= mintedToDifferentWallet; + + // mint to different wallet + const res1 = await neutronClient.execute(contractAddress, { + mint_tokens: { + denom, + amount: mintedToDifferentWallet.toString(), + mint_to_address: wallet2.address, + }, + }); + expect(res1.code).toBe(0); + + const balanceBefore = await neutronClient.getBalance( + wallet2.address, + denom, + ); + expect(balanceBefore.amount).toBe(mintedToDifferentWallet.toString()); + + const res = await neutronClient.execute(contractAddress, { + burn_tokens: { + denom, + amount: toBurn.toString(), + burn_from_address: wallet2.address, + }, + }); + expect(res.code).toBe(0); + + await neutronClient.waitBlocks(5); + + const balanceAfter = await neutronClient.getBalance( + wallet2.address, + denom, + ); + expect(balanceAfter.amount).toBe(leftAfterBurn.toString()); + }); + test('full denom query', async () => { const res = await neutronClient.queryContractSmart(contractAddress, { full_denom: { creator_addr: contractAddress, subdenom }, From c4c485649861abe0f3f3c903bc6cf9b55e9a5d7d Mon Sep 17 00:00:00 2001 From: nhpd Date: Thu, 22 Aug 2024 18:16:52 +0400 Subject: [PATCH 2/2] cleanup --- src/testcases/run_in_band/tokenfactory.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/testcases/run_in_band/tokenfactory.test.ts b/src/testcases/run_in_band/tokenfactory.test.ts index c4750e5b..2b84f329 100644 --- a/src/testcases/run_in_band/tokenfactory.test.ts +++ b/src/testcases/run_in_band/tokenfactory.test.ts @@ -445,8 +445,6 @@ describe('Neutron / Tokenfactory', () => { ); expect(burnRes.code).toBe(0); - // TODO: test burn from different address? - const balanceAfter = parseInt( (await neutronClient.getBalance(neutronWallet.address, newTokenDenom)) .amount,