-
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
ffe16fa
commit de45e2d
Showing
1 changed file
with
33 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,44 @@ | ||
use near_workspaces::types::NearToken; | ||
|
||
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 set_permission_result = contract | ||
.call("set_permission") | ||
.args_json(json!({ | ||
"path": "test", | ||
"account_id": "peter", | ||
"permission": 0x01 | ||
})) | ||
.deposit(NearToken::from_millinear(100)) | ||
.transact() | ||
.await?; | ||
assert!(set_permission_result.is_success()); | ||
|
||
let get_permission_result: serde_json::Value = contract | ||
.call("get_permission") | ||
.args_json(json!({ | ||
"path": "test", | ||
"account_id": "peter" | ||
})) | ||
.view() | ||
.await? | ||
.json()?; | ||
|
||
assert_eq!(1, get_permission_result); | ||
|
||
let wasm = near_workspaces::compile_project("./").await?; | ||
|
||
let mut contract_upgrade_result = | ||
contract.call("unsafe_self_upgrade").args(wasm).max_gas().transact().await?; | ||
let mut contract_upgrade_result = contract | ||
.call("unsafe_self_upgrade") | ||
.args(wasm) | ||
.max_gas() | ||
.transact() | ||
.await?; | ||
|
||
Ok(()) | ||
} | ||
} |