-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86f7d45
commit 018ec17
Showing
4 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,14 @@ | ||
mod test_env; | ||
|
||
use {crate::test_env::*, serde_json::json}; | ||
|
||
#[tokio::test] | ||
async fn test_deploy_contract_self_upgrade() -> anyhow::Result<()> { | ||
let contract = init_contracts().await?; | ||
let wasm = near_workspaces::compile_project("./").await?; | ||
|
||
let mut contract_upgrade_result = | ||
contract.call("unsafe_self_upgrade").args(wasm).max_gas().transact().await?; | ||
|
||
Ok(()) | ||
} |
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,22 @@ | ||
use near_units::parse_near; | ||
use near_workspaces::{AccountId, types::NearToken}; | ||
use serde_json::json; | ||
|
||
const WASMGIT_CONTRACT: &str = "wasmgit.near"; | ||
|
||
pub async fn init_contracts() -> anyhow::Result<near_workspaces::Contract> { | ||
let worker = near_workspaces::sandbox().await?; | ||
let mainnet = near_workspaces::mainnet_archival().await?; | ||
|
||
let contract_id: AccountId = WASMGIT_CONTRACT.parse()?; | ||
let contract = worker | ||
.import_contract(&contract_id, &mainnet) | ||
.initial_balance(NearToken::from_near(parse_near!("1000 N"))) | ||
.transact() | ||
.await?; | ||
let outcome = contract.call("new").args_json(json!({})).transact().await?; | ||
assert!(outcome.is_success()); | ||
assert!(format!("{:?}", outcome).contains("Migrated to version:")); | ||
|
||
Ok(contract) | ||
} |