Skip to content

Commit

Permalink
Merge pull request #46 from osmosis-labs/wip-0.3.0-final
Browse files Browse the repository at this point in the history
Update to use final 0.3.0 contracts
  • Loading branch information
ethanfrey authored Jun 28, 2023
2 parents 851b667 + 1abaa62 commit 394407a
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 4 deletions.
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
// 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

0 comments on commit 394407a

Please sign in to comment.