stargate: Add Amino signer test for sendTokens

This commit is contained in:
willclarktech 2021-01-13 12:04:42 +00:00
parent 8d1d745fc8
commit 2548ed7a81
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7

View File

@ -126,7 +126,7 @@ describe("SigningStargateClient", () => {
});
describe("sendTokens", () => {
it("works", async () => {
it("works with direct signer", async () => {
pendingWithoutSimapp();
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucet.mnemonic);
const client = await SigningStargateClient.connectWithSigner(simapp.tendermintUrl, wallet);
@ -149,6 +149,30 @@ describe("SigningStargateClient", () => {
assert(after);
expect(after).toEqual(transferAmount[0]);
});
it("works with legacy Amino signer", async () => {
pendingWithoutSimapp();
const wallet = await Secp256k1HdWallet.fromMnemonic(faucet.mnemonic);
const client = await SigningStargateClient.connectWithSigner(simapp.tendermintUrl, wallet);
const transferAmount = coins(7890, "ucosm");
const beneficiaryAddress = makeRandomAddress();
const memo = "for dinner";
// no tokens here
const before = await client.getBalance(beneficiaryAddress, "ucosm");
expect(before).toBeNull();
// send
const result = await client.sendTokens(faucet.address0, beneficiaryAddress, transferAmount, memo);
assertIsBroadcastTxSuccess(result);
expect(result.rawLog).toBeTruthy();
// got tokens
const after = await client.getBalance(beneficiaryAddress, "ucosm");
assert(after);
expect(after).toEqual(transferAmount[0]);
});
});
describe("signAndBroadcast", () => {