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

Update to use final 0.3.0 contracts #46

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
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
16 changes: 15 additions & 1 deletion tests/e2e/mvp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,22 @@ func TestMVP(t *testing.T) {

assert.Equal(t, 70_000_000, providerCli.QueryVaultFreeBalance())

// Cross Stake - A user pulls out additional liens on the same collateral "cross staking" it on different chains.
// @alpe these lines pass, but when I run them, the following providerCli.MustExecVault(execMsg) fails with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I will add fix to wasmd and make this work here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be happy for merge and release of this (so we have 0.3.0 mesh-security-sdk that can be tested).

And then the wasmd stuff afterwards in a patch release. Test works and shows it is enforced, but it breaks others. This is more about maintainability than correctness of current code, so can add to a patch

// account sequence mismatch, expected 20, got 19: incorrect account sequence
// Because TestChain only updates sequence on success...
// https://github.com/CosmWasm/wasmd/blob/main/x/wasm/ibctesting/chain.go#L372-L383
// At error should happen at the bottom, when all processed, not an early return
//
// // Failure mode of cross-stake... trying to stake to an unknown validator
// execMsg = fmt.Sprintf(`{"stake_remote":{"contract":"%s", "amount": {"denom":%q, "amount":"%d"}, "msg":%q}}`,
// providerContracts.externalStaking.String(),
// sdk.DefaultBondDenom, 80_000_000,
// base64.StdEncoding.EncodeToString([]byte(`{"validator": "BAD-VALIDATOR"}`)))
// providerCli.VaultShouldFail(execMsg)
// // no change to free balance
// assert.Equal(t, 70_000_000, providerCli.QueryVaultFreeBalance())

// Cross Stake - A user pulls out additional liens on the same collateral "cross staking" it on different chains.
execMsg = fmt.Sprintf(`{"stake_remote":{"contract":"%s", "amount": {"denom":%q, "amount":"%d"}, "msg":%q}}`,
providerContracts.externalStaking.String(),
sdk.DefaultBondDenom, 80_000_000,
Expand Down
23 changes: 21 additions & 2 deletions tests/e2e/test_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,23 @@ func (p TestProviderClient) mustExec(contract sdk.AccAddress, payload string, fu
return rsp
}

func (p TestProviderClient) VaultShouldFail(payload string, funds ...sdk.Coin) error {
return p.execShouldFail(p.contracts.vault, payload, funds)
}

// This will execute the contract and assert that it fails, returning the error if desired.
// (Unlike most functions, it will panic on failure, returning error is success case)
func (p TestProviderClient) execShouldFail(contract sdk.AccAddress, payload string, funds []sdk.Coin) error {
resp, err := p.chain.SendMsgs(&wasmtypes.MsgExecuteContract{
Sender: p.chain.SenderAccount.GetAddress().String(),
Contract: contract.String(),
Msg: []byte(payload),
Funds: funds,
})
require.Error(p.t, err, "Response: %v", resp)
return err
}

func (p TestProviderClient) QueryExtStaking(q Query) map[string]any {
return Querier(p.t, p.chain)(p.contracts.externalStaking.String(), q)
}
Expand All @@ -105,8 +122,10 @@ func (p TestProviderClient) QueryVaultFreeBalance() int {
qRsp := p.QueryVault(Query{
"account": {"account": p.chain.SenderAccount.GetAddress().String()},
})
require.NotEmpty(p.t, qRsp["free"], qRsp)
r, err := strconv.Atoi(qRsp["free"].(string))
require.NotEmpty(p.t, qRsp["account"], qRsp)
acct := qRsp["account"].(map[string]any)
require.NotEmpty(p.t, acct["free"], qRsp)
r, err := strconv.Atoi(acct["free"].(string))
require.NoError(p.t, err, qRsp)
return r
}
Expand Down
Binary file modified tests/e2e/testdata/external_staking.wasm.gz
Binary file not shown.
Binary file modified tests/e2e/testdata/mesh_converter.wasm.gz
Binary file not shown.
Binary file modified tests/e2e/testdata/mesh_native_staking.wasm.gz
Binary file not shown.
Binary file modified tests/e2e/testdata/mesh_native_staking_proxy.wasm.gz
Binary file not shown.
Binary file modified tests/e2e/testdata/mesh_simple_price_feed.wasm.gz
Binary file not shown.
Binary file modified tests/e2e/testdata/mesh_vault.wasm.gz
Binary file not shown.
Binary file modified tests/e2e/testdata/mesh_virtual_staking.wasm.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/e2e/testdata/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b5c8df0764aae9928795d5705788816dd0df3e70
v0.3.0