Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(system): check feePayers signature #22389

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions tests/systemtests/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
JulianToledano marked this conversation as resolved.
Show resolved Hide resolved
}
Loading