-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FeeShare: Authz payout support (#845)
* use BinaryCodec for Unpacking Authz msgs * Recursively Search Authz Msgs * Add Ante Unit Tests * Lint * Add Interchain Tests for Authz * Remove Debug Statement * Fix Type Issues * Fix Math Int Conversion * mv -> `ExecuteAuthzGrantMsg` & rm unused args --------- Co-authored-by: Joel Smith <[email protected]>
- Loading branch information
1 parent
d48ff12
commit a56c442
Showing
6 changed files
with
316 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package helpers | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/crypto/keyring" | ||
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" | ||
"github.com/strangelove-ventures/interchaintest/v7/ibc" | ||
"github.com/strangelove-ventures/interchaintest/v7/testutil" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func ExecuteAuthzGrantMsg(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, granter ibc.Wallet, grantee ibc.Wallet, msgType string) { | ||
if !strings.HasPrefix(msgType, "/") { | ||
msgType = "/" + msgType | ||
} | ||
|
||
cmd := []string{ | ||
"junod", "tx", "authz", "grant", grantee.FormattedAddress(), "generic", | ||
"--msg-type", msgType, | ||
"--node", chain.GetRPCAddress(), | ||
"--home", chain.HomeDir(), | ||
"--chain-id", chain.Config().ChainID, | ||
"--from", granter.KeyName(), | ||
"--gas", "500000", | ||
"--keyring-dir", chain.HomeDir(), | ||
"--keyring-backend", keyring.BackendTest, | ||
"-y", | ||
} | ||
|
||
stdout, _, err := chain.Exec(ctx, cmd, nil) | ||
require.NoError(t, err) | ||
|
||
debugOutput(t, string(stdout)) | ||
|
||
if err := testutil.WaitForBlocks(ctx, 2, chain); err != nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
func ExecuteAuthzExecMsgWithFee(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, grantee ibc.Wallet, contractAddr, amount, feeCoin, message string) { | ||
// Get the node to execute the command & write output to file | ||
node := chain.Nodes()[0] | ||
filePath := "authz.json" | ||
generateMsg := []string{ | ||
"junod", "tx", "wasm", "execute", contractAddr, message, | ||
"--home", chain.HomeDir(), | ||
"--chain-id", chain.Config().ChainID, | ||
"--from", grantee.KeyName(), | ||
"--gas", "500000", | ||
"--fees", feeCoin, | ||
"--keyring-dir", chain.HomeDir(), | ||
"--keyring-backend", keyring.BackendTest, | ||
"--generate-only", | ||
} | ||
|
||
// Generate msg output | ||
res, resErr, err := node.Exec(ctx, generateMsg, nil) | ||
if resErr != nil { | ||
t.Fatal(resErr) | ||
} | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// Write output to file | ||
err = node.WriteFile(ctx, res, filePath) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// Execute the command | ||
cmd := []string{ | ||
"junod", "tx", "authz", "exec", node.HomeDir() + "/" + filePath, | ||
"--node", chain.GetRPCAddress(), | ||
"--home", chain.HomeDir(), | ||
"--chain-id", chain.Config().ChainID, | ||
"--from", grantee.KeyName(), | ||
"--gas", "500000", | ||
"--fees", feeCoin, | ||
"--keyring-dir", chain.HomeDir(), | ||
"--keyring-backend", keyring.BackendTest, | ||
"-y", | ||
} | ||
|
||
if amount != "" { | ||
cmd = append(cmd, "--amount", amount) | ||
} | ||
|
||
stdout, _, err := chain.Exec(ctx, cmd, nil) | ||
require.NoError(t, err) | ||
|
||
debugOutput(t, string(stdout)) | ||
|
||
if err := testutil.WaitForBlocks(ctx, 2, chain); err != nil { | ||
t.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.