Skip to content

Commit

Permalink
Merge pull request #41 from osmosis-labs/40_wasm_path
Browse files Browse the repository at this point in the history
Configurable path to wasm contract files
  • Loading branch information
alpe authored Jun 8, 2023
2 parents 7143902 + 9ff2ec1 commit 0ddd6d4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
16 changes: 16 additions & 0 deletions tests/e2e/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package e2e

import (
"flag"
"os"
"testing"
)

var wasmContractPath string

func TestMain(m *testing.M) {
flag.StringVar(&wasmContractPath, "contracts-path", "testdata", "Set path to dir with gzipped wasm contracts")
flag.Parse()

os.Exit(m.Run())
}
15 changes: 8 additions & 7 deletions tests/e2e/mvp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package e2e
import (
"encoding/base64"
"fmt"
"path/filepath"
"testing"

"cosmossdk.io/math"
Expand Down Expand Up @@ -182,17 +183,17 @@ type ProviderContracts struct {
}

func bootstrapProviderContracts(t *testing.T, chain *wasmibctesting.TestChain) ProviderContracts {
vaultCodeID := chain.StoreCodeFile("testdata/mesh_vault.wasm.gz").CodeID
proxyCodeID := chain.StoreCodeFile("testdata/mesh_native_staking_proxy.wasm.gz").CodeID
nativeStakingCodeID := chain.StoreCodeFile("testdata/mesh_native_staking.wasm.gz").CodeID
vaultCodeID := chain.StoreCodeFile(filepath.Join(wasmContractPath, "mesh_vault.wasm.gz")).CodeID
proxyCodeID := chain.StoreCodeFile(filepath.Join(wasmContractPath, "mesh_native_staking_proxy.wasm.gz")).CodeID
nativeStakingCodeID := chain.StoreCodeFile(filepath.Join(wasmContractPath, "mesh_native_staking.wasm.gz")).CodeID

nativeInitMsg := []byte(fmt.Sprintf(`{"denom": %q, "proxy_code_id": %d}`, sdk.DefaultBondDenom, proxyCodeID))
initMsg := []byte(fmt.Sprintf(`{"denom": %q, "local_staking": {"code_id": %d, "msg": %q}}`, sdk.DefaultBondDenom, nativeStakingCodeID, base64.StdEncoding.EncodeToString(nativeInitMsg)))
vaultContract := InstantiateContract(t, chain, vaultCodeID, initMsg)

// external staking
unbondingPeriod := 21 * 24 * 60 * 60 // 21 days - make configurable?
extStakingCodeID := chain.StoreCodeFile("testdata/external_staking.wasm.gz").CodeID
extStakingCodeID := chain.StoreCodeFile(filepath.Join(wasmContractPath, "external_staking.wasm.gz")).CodeID
rewardToken := "todo" // ics20 token
initMsg = []byte(fmt.Sprintf(`{"denom": %q, "vault": %q, "unbonding_period": %d, "rewards_denom": %q}`, sdk.DefaultBondDenom, vaultContract.String(), unbondingPeriod, rewardToken))
externalStakingContract := InstantiateContract(t, chain, extStakingCodeID, initMsg)
Expand All @@ -210,15 +211,15 @@ type ConsumerContract struct {
}

func bootstrapConsumerContracts(t *testing.T, consumerChain *wasmibctesting.TestChain) ConsumerContract {
codeID := consumerChain.StoreCodeFile("testdata/mesh_simple_price_feed.wasm.gz").CodeID
codeID := consumerChain.StoreCodeFile(filepath.Join(wasmContractPath, "mesh_simple_price_feed.wasm.gz")).CodeID
initMsg := []byte(fmt.Sprintf(`{"native_per_foreign": "%s"}`, "0.5")) // todo: configure price
priceFeedContract := InstantiateContract(t, consumerChain, codeID, initMsg)
// instantiate virtual staking contract
codeID = consumerChain.StoreCodeFile("testdata/mesh_virtual_staking.wasm.gz").CodeID
codeID = consumerChain.StoreCodeFile(filepath.Join(wasmContractPath, "mesh_virtual_staking.wasm.gz")).CodeID
initMsg = []byte(fmt.Sprintf(`{"denom": %q}`, sdk.DefaultBondDenom))
stakingContract := InstantiateContract(t, consumerChain, codeID, initMsg)
// instantiate converter
codeID = consumerChain.StoreCodeFile("testdata/mesh_converter.wasm.gz").CodeID
codeID = consumerChain.StoreCodeFile(filepath.Join(wasmContractPath, "mesh_converter.wasm.gz")).CodeID
initMsg = []byte(fmt.Sprintf(`{"price_feed": %q, "virtual_staking": %q, "discount": "0.1"}`, priceFeedContract.String(), stakingContract.String())) // todo: configure price
converterContract := InstantiateContract(t, consumerChain, codeID, initMsg)

Expand Down

0 comments on commit 0ddd6d4

Please sign in to comment.