test(system): check feePayers signature (#22389)
This commit is contained in:
parent
22231f7c6d
commit
7b9a89b568
@ -492,3 +492,56 @@ func TestTxEncodeandDecode(t *testing.T) {
|
||||
decodedTx := cli.RunCommandWithArgs("tx", "decode", encodedText)
|
||||
require.Equal(t, gjson.Get(decodedTx, "body.memo").String(), memoText)
|
||||
}
|
||||
|
||||
func TestTxWithFeePayer(t *testing.T) {
|
||||
// Scenario:
|
||||
// send a tx with FeePayer without his signature
|
||||
// check tx fails
|
||||
// send tx with feePayers signature
|
||||
// check tx executed ok
|
||||
// check fees had been deducted from feePayers balance
|
||||
|
||||
sut.ResetChain(t)
|
||||
cli := NewCLIWrapper(t, sut, verbose).WithRunErrorsIgnored()
|
||||
|
||||
// add sender and feePayer accounts
|
||||
senderAddr := cli.AddKey("sender")
|
||||
sut.ModifyGenesisCLI(t,
|
||||
[]string{"genesis", "add-genesis-account", senderAddr, "10000000stake"},
|
||||
)
|
||||
feePayerAddr := cli.AddKey("feePayer")
|
||||
sut.ModifyGenesisCLI(t,
|
||||
[]string{"genesis", "add-genesis-account", feePayerAddr, "10000000stake"},
|
||||
)
|
||||
|
||||
sut.StartChain(t)
|
||||
|
||||
// send a tx with FeePayer without his signature
|
||||
rsp := cli.RunCommandWithArgs(cli.withTXFlags(
|
||||
"tx", "bank", "send", senderAddr, "cosmos108jsm625z3ejy63uef2ke7t67h6nukt4ty93nr", "1000stake", "--fees", "1000000stake", "--fee-payer", feePayerAddr,
|
||||
)...)
|
||||
RequireTxFailure(t, rsp, "invalid number of signatures")
|
||||
|
||||
// send tx with feePayers signature
|
||||
rsp = cli.RunCommandWithArgs(cli.withTXFlags(
|
||||
"tx", "bank", "send", senderAddr, "cosmos108jsm625z3ejy63uef2ke7t67h6nukt4ty93nr", "1000stake", "--fees", "1000000stake", "--fee-payer", feePayerAddr, "--generate-only",
|
||||
)...)
|
||||
tempFile := StoreTempFile(t, []byte(rsp))
|
||||
|
||||
rsp = cli.RunCommandWithArgs(cli.withTXFlags(
|
||||
"tx", "sign", tempFile.Name(), "--from", senderAddr, "--sign-mode", "amino-json",
|
||||
)...)
|
||||
tempFile = StoreTempFile(t, []byte(rsp))
|
||||
|
||||
rsp = cli.RunCommandWithArgs(cli.withTXFlags(
|
||||
"tx", "sign", tempFile.Name(), "--from", feePayerAddr, "--sign-mode", "amino-json",
|
||||
)...)
|
||||
tempFile = StoreTempFile(t, []byte(rsp))
|
||||
|
||||
rsp = cli.RunAndWait([]string{"tx", "broadcast", tempFile.Name()}...)
|
||||
RequireTxSuccess(t, rsp)
|
||||
|
||||
// Query to check fee has been deducted from feePayer
|
||||
balance := cli.QueryBalance(feePayerAddr, authTestDenom)
|
||||
assert.Equal(t, balance, int64(9000000))
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user