Skip to content

Commit

Permalink
Update DEX WASM tests to work with the update version of the WASM SDK. (
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitryhil authored Nov 25, 2024
1 parent 31502e2 commit 1f99518
Show file tree
Hide file tree
Showing 26 changed files with 45 additions and 54 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ cosmwasm-std = { version = "2.1.4", features = ["cosmwasm_2_0"] }
cw2 = "2.0.0"
cw-storage-plus = "2.0.0"
cosmwasm-schema = "2.1.4"
coreum-wasm-sdk = { git = "https://github.com/CoreumFoundation/coreum-wasm-sdk.git" }
coreum-wasm-sdk = { git = "https://github.com/CoreumFoundation/coreum-wasm-sdk.git", rev = "a0a00147d65b409bef2d86ebebf35959c96263c3" }
cw-utils = "2.0.0"
prost = "0.12.6"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use coreum_wasm_sdk::core::CoreumResult;
use coreum_wasm_sdk::deprecated::core::CoreumResult;
use coreum_wasm_sdk::shim;
use coreum_wasm_sdk::types::cosmos::authz::v1beta1::MsgExec;
use coreum_wasm_sdk::types::cosmos::bank::v1beta1::MsgSend as BankMsg;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ thiserror = "1.0.56"
cosmwasm-std = { version = "2.1.4", features = ["stargate", "cosmwasm_2_0"] }
cw2 = "2.0.0"
cosmwasm-schema = "2.1.4"
coreum-wasm-sdk = { git = "https://github.com/CoreumFoundation/coreum-wasm-sdk.git" }
coreum-wasm-sdk = { git = "https://github.com/CoreumFoundation/coreum-wasm-sdk.git", rev = "a0a00147d65b409bef2d86ebebf35959c96263c3" }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use coreum_wasm_sdk::core::CoreumResult;
use coreum_wasm_sdk::deprecated::core::CoreumResult;

#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ cosmwasm-std = { version = "2.1.4", features = ["cosmwasm_2_0"] }
cw2 = "2.0.0"
cw-storage-plus = "2.0.0"
cosmwasm-schema = "2.1.4"
coreum-wasm-sdk = { git = "https://github.com/CoreumFoundation/coreum-wasm-sdk.git" }
coreum-wasm-sdk = { git = "https://github.com/CoreumFoundation/coreum-wasm-sdk.git", rev = "a0a00147d65b409bef2d86ebebf35959c96263c3" }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use coreum_wasm_sdk::core::CoreumResult;
use coreum_wasm_sdk::deprecated::core::CoreumResult;
use coreum_wasm_sdk::shim;
use coreum_wasm_sdk::types::cosmos::authz::v1beta1::MsgExec;
use coreum_wasm_sdk::types::cosmos::bank::v1beta1::MsgSend;
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/contracts/modules/bank-send/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration-tests/contracts/modules/bank-send/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ library = []

[dependencies]
cosmwasm-std = { version = "2.1.4", features = ["cosmwasm_2_0"] }
coreum-wasm-sdk = { git = "https://github.com/CoreumFoundation/coreum-wasm-sdk.git" }
coreum-wasm-sdk = { git = "https://github.com/CoreumFoundation/coreum-wasm-sdk.git", rev = "a0a00147d65b409bef2d86ebebf35959c96263c3" }
cw-storage-plus = "2.0.0"
cw2 = "2.0.0"
thiserror = "1.0.59"
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/contracts/modules/dex/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration-tests/contracts/modules/dex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ cosmwasm-std = { version = "2.1.4", features = ["cosmwasm_2_0"] }
cw-storage-plus = "2.0.0"
cw2 = "2.0.0"
thiserror = "1.0.59"
coreum-wasm-sdk = { git = "https://github.com/CoreumFoundation/coreum-wasm-sdk.git" }
coreum-wasm-sdk = { git = "https://github.com/CoreumFoundation/coreum-wasm-sdk.git", rev = "a0a00147d65b409bef2d86ebebf35959c96263c3" }
cosmwasm-schema = "2.1.4"
cw-ownable = "2.1.0"
2 changes: 1 addition & 1 deletion integration-tests/contracts/modules/dex/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub fn execute(

// ********** Transactions **********

fn place_order(env: Env, order: Order) -> Result<Response, ContractError> {
fn place_order(env: Env, order: MsgPlaceOrder) -> Result<Response, ContractError> {
let place_order = MsgPlaceOrder {
sender: env.contract.address.to_string(),
r#type: order.r#type,
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/contracts/modules/dex/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use coreum_wasm_sdk::types::coreum::asset::ft::v1::{DexSettings, ExtensionIssueSettings};
use coreum_wasm_sdk::types::coreum::dex::v1::Order;
use coreum_wasm_sdk::types::coreum::dex::v1::{MsgPlaceOrder, Order};
use cosmwasm_schema::cw_serde;
use cosmwasm_std::Uint128;

Expand All @@ -21,7 +21,7 @@ pub struct InstantiateMsg {

#[cw_serde]
pub enum ExecuteMsg {
PlaceOrder { order: Order },
PlaceOrder { order: MsgPlaceOrder },
CancelOrder { order_id: String },
CancelOrdersByDenom { account: String, denom: String },
}
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/contracts/modules/ft-legacy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ cosmwasm-storage = "1.5.0"
cw-storage-plus = "1.1.0"
cw2 = "1.1.1"
thiserror = "1.0.50"
coreum-wasm-sdk = "1.0.0"
coreum-wasm-sdk = "1.0.0" # we use old version intentionally
cosmwasm-schema = "1.4.1"
cw-ownable = "0.5.1"
2 changes: 1 addition & 1 deletion integration-tests/contracts/modules/ft/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration-tests/contracts/modules/ft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ cosmwasm-std = { version = "2.1.4", features = ["cosmwasm_2_0"] }
cw-storage-plus = "2.0.0"
cw2 = "2.0.0"
thiserror = "1.0.59"
coreum-wasm-sdk = { git = "https://github.com/CoreumFoundation/coreum-wasm-sdk.git" }
coreum-wasm-sdk = { git = "https://github.com/CoreumFoundation/coreum-wasm-sdk.git", rev = "a0a00147d65b409bef2d86ebebf35959c96263c3" }
cosmwasm-schema = "2.1.4"
cw-ownable = "2.1.0"
2 changes: 1 addition & 1 deletion integration-tests/contracts/modules/nft-legacy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ cw-storage-plus = "1.2.0"
cw2 = "1.1.2"
thiserror = "1.0.59"
schemars = "0.8.16"
coreum-wasm-sdk = "1.0.0"
coreum-wasm-sdk = "1.0.0" # we use old version intentionally
cosmwasm-schema = "1.5.4"
cw-ownable = "0.5.1"
2 changes: 1 addition & 1 deletion integration-tests/contracts/modules/nft/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration-tests/contracts/modules/nft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ cw-storage-plus = "2.0.0"
cw2 = "2.0.0"
thiserror = "1.0.59"
schemars = "0.8.16"
coreum-wasm-sdk = { git = "https://github.com/CoreumFoundation/coreum-wasm-sdk.git" }
coreum-wasm-sdk = { git = "https://github.com/CoreumFoundation/coreum-wasm-sdk.git", rev = "a0a00147d65b409bef2d86ebebf35959c96263c3" }
cosmwasm-schema = "2.1.4"
cw-ownable = "2.1.0"
9 changes: 2 additions & 7 deletions integration-tests/modules/dex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2333,8 +2333,8 @@ func TestAssetFTBlockSmartContractsFeatureWithDEX(t *testing.T) {

placeOrderPayload, err := json.Marshal(map[dexMethod]placeOrderBodyDEXRequest{
dexMethodPlaceOrder: {
Order: dextypes.Order{
Creator: contractAddr,
Order: dextypes.MsgPlaceOrder{
Sender: contractAddr,
Type: dextypes.ORDER_TYPE_LIMIT,
ID: "id1",
BaseDenom: denom1WithBlockSmartContract,
Expand All @@ -2343,11 +2343,6 @@ func TestAssetFTBlockSmartContractsFeatureWithDEX(t *testing.T) {
Quantity: sdkmath.NewInt(100),
Side: dextypes.SIDE_BUY,
TimeInForce: dextypes.TIME_IN_FORCE_GTC,
// next attributes are required by smart contract, but not used
RemainingQuantity: sdkmath.ZeroInt(),
RemainingBalance: sdkmath.ZeroInt(),
GoodTil: nil,
Reserve: sdk.NewCoin("denom1", sdkmath.ZeroInt()),
},
},
})
Expand Down
38 changes: 17 additions & 21 deletions integration-tests/modules/wasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ type accountBodyFTRequest struct {
}

type placeOrderBodyDEXRequest struct {
Order dextypes.Order `json:"order"`
Order dextypes.MsgPlaceOrder `json:"order"`
}

//nolint:tagliatelle
Expand Down Expand Up @@ -3613,8 +3613,6 @@ func TestVestingToWASMContract(t *testing.T) {

// TestWASMDEXInContract verifies that smart contract is able to execute all Coreum DEX messages and queries.
func TestWASMDEXInContract(t *testing.T) {
t.Skip() // FIXME(dzmitryhil) restore once we merge and regenerate protos and contract

t.Parallel()

ctx, chain := integrationtests.NewCoreumTestingContext(t)
Expand Down Expand Up @@ -3768,8 +3766,8 @@ func TestWASMDEXInContract(t *testing.T) {
orderQuantity := sdkmath.NewInt(100)
placeOrderPayload, err := json.Marshal(map[dexMethod]placeOrderBodyDEXRequest{
dexMethodPlaceOrder: {
Order: dextypes.Order{
Creator: contractAddr,
Order: dextypes.MsgPlaceOrder{
Sender: contractAddr,
Type: dextypes.ORDER_TYPE_LIMIT,
ID: "id1",
BaseDenom: denom1,
Expand All @@ -3780,10 +3778,7 @@ func TestWASMDEXInContract(t *testing.T) {
GoodTil: &dextypes.GoodTil{
GoodTilBlockHeight: uint64(blockRes.SdkBlock.Header.Height + 500),
},
TimeInForce: dextypes.TIME_IN_FORCE_GTC,
RemainingQuantity: orderQuantity,
RemainingBalance: orderQuantity,
Reserve: wasmParamsRes.Params.OrderReserve,
TimeInForce: dextypes.TIME_IN_FORCE_GTC,
},
},
})
Expand All @@ -3801,12 +3796,25 @@ func TestWASMDEXInContract(t *testing.T) {

// ********** Query Order **********

orderPayload, err := json.Marshal(map[dexMethod]OrderBodyDEXRequest{
dexMethodOrder: {
Account: contractAddr,
OrderID: "id1",
},
})
requireT.NoError(err)
queryOut, err = chain.Wasm.QueryWASMContract(ctx, contractAddr, orderPayload)
requireT.NoError(err)
var wasmOrderRes dextypes.QueryOrderResponse
requireT.NoError(json.Unmarshal(queryOut, &wasmOrderRes))

expectedOrder := dextypes.Order{
Creator: contractAddr,
Type: dextypes.ORDER_TYPE_LIMIT,
ID: "id1",
BaseDenom: denom1,
QuoteDenom: denom2,
Sequence: wasmOrderRes.Order.Sequence,
Price: lo.ToPtr(dextypes.MustNewPriceFromString("999")),
Quantity: orderQuantity,
Side: dextypes.SIDE_SELL,
Expand All @@ -3818,18 +3826,6 @@ func TestWASMDEXInContract(t *testing.T) {
RemainingBalance: orderQuantity,
Reserve: dexParms.OrderReserve,
}

orderPayload, err := json.Marshal(map[dexMethod]OrderBodyDEXRequest{
dexMethodOrder: {
Account: contractAddr,
OrderID: "id1",
},
})
requireT.NoError(err)
queryOut, err = chain.Wasm.QueryWASMContract(ctx, contractAddr, orderPayload)
requireT.NoError(err)
var wasmOrderRes dextypes.QueryOrderResponse
requireT.NoError(json.Unmarshal(queryOut, &wasmOrderRes))
requireT.Equal(expectedOrder, wasmOrderRes.Order)

// ********** Query Orders **********
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cosmwasm-std = { version = "2.1.4", features = ["cosmwasm_2_0"] }
cw2 = "2.0.0"
thiserror = "1.0.59"
cosmwasm-schema = "2.1.4"
coreum-wasm-sdk = { git = "https://github.com/CoreumFoundation/coreum-wasm-sdk.git" }
coreum-wasm-sdk = { git = "https://github.com/CoreumFoundation/coreum-wasm-sdk.git", rev = "a0a00147d65b409bef2d86ebebf35959c96263c3" }
cw-storage-plus = "2.0.0"
prost = "0.11.9"
serde = { version = "1.0.203", default-features = false, features = ["derive"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::msg::{
TransferContext,
};
use crate::state::{DENOM, EXTRA_DATA};
use coreum_wasm_sdk::assetft::{FREEZING, WHITELISTING};
use coreum_wasm_sdk::core::{CoreumMsg, CoreumResult};
use coreum_wasm_sdk::deprecated::assetft::{FREEZING, WHITELISTING};
use coreum_wasm_sdk::deprecated::core::{CoreumMsg, CoreumResult};
use coreum_wasm_sdk::types::coreum::asset::ft::v1::{
MsgBurn, MsgMint, QueryFrozenBalanceRequest, QueryFrozenBalanceResponse, QueryTokenRequest,
QueryTokenResponse, QueryWhitelistedBalanceRequest, QueryWhitelistedBalanceResponse, Token,
Expand Down

0 comments on commit 1f99518

Please sign in to comment.