-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Integrate contract migration * Migrate the contract before the integration tests start * Add migration integration test * Add migration CLI and instructions
- Loading branch information
1 parent
993f8ed
commit 8e30198
Showing
24 changed files
with
371 additions
and
71 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
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 |
---|---|---|
|
@@ -12,3 +12,4 @@ pub mod state; | |
mod tests; | ||
pub mod tickets; | ||
pub mod token; | ||
pub mod migration; |
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,24 @@ | ||
use crate::error::ContractError; | ||
|
||
use cosmwasm_std::entry_point; | ||
use cosmwasm_std::{ | ||
DepsMut, Env, Response, StdError, | ||
}; | ||
|
||
use cw2::set_contract_version; | ||
|
||
const CONTRACT_NAME: &str = env!("CARGO_PKG_NAME"); | ||
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); | ||
|
||
use crate::msg::{MigrateMsg}; | ||
|
||
#[entry_point] | ||
pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> { | ||
let ver = cw2::get_contract_version(deps.storage)?; | ||
if ver.contract != CONTRACT_NAME { | ||
return Err(StdError::generic_err("Can only upgrade from same contract type").into()); | ||
} | ||
// TODO Add migration logic, and version validation | ||
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; | ||
Ok(Response::default()) | ||
} |
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
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
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,50 @@ | ||
//go:build integrationtests | ||
// +build integrationtests | ||
|
||
package contract_test | ||
|
||
import ( | ||
"testing" | ||
|
||
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" | ||
"github.com/stretchr/testify/require" | ||
|
||
integrationtests "github.com/CoreumFoundation/coreumbridge-xrpl/integration-tests" | ||
"github.com/CoreumFoundation/coreumbridge-xrpl/relayer/xrpl" | ||
) | ||
|
||
func TestContractMigration(t *testing.T) { | ||
t.Parallel() | ||
|
||
ctx, chains := integrationtests.NewTestingContext(t) | ||
relayers := genRelayers(ctx, t, chains, 2) | ||
|
||
wasmClient := wasmtypes.NewQueryClient(chains.Coreum.ClientContext) | ||
|
||
xrplBridgeAddress := xrpl.GenPrivKeyTxSigner().Account() | ||
xrplBaseFee := uint32(10) | ||
owner, contractClient := integrationtests.DeployAndInstantiateContractV110( | ||
ctx, | ||
t, | ||
chains, | ||
relayers, | ||
uint32(len(relayers)), | ||
5, | ||
defaultTrustSetLimitAmount, | ||
xrplBridgeAddress.String(), | ||
xrplBaseFee, | ||
) | ||
|
||
contractInfoBeforeMigration, err := wasmClient.ContractInfo(ctx, &wasmtypes.QueryContractInfoRequest{ | ||
Address: contractClient.GetContractAddress().String(), | ||
}) | ||
require.NoError(t, err) | ||
|
||
integrationtests.MigrateContract(ctx, t, contractClient, owner) | ||
|
||
contractInfoAfterMigration, err := wasmClient.ContractInfo(ctx, &wasmtypes.QueryContractInfoRequest{ | ||
Address: contractClient.GetContractAddress().String(), | ||
}) | ||
require.NoError(t, err) | ||
require.NotEqual(t, contractInfoBeforeMigration.CodeID, contractInfoAfterMigration.CodeID) | ||
} |
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.