Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: bump near-workspaces-rs to 0.9 #862

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 6 additions & 40 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ near-sdk = "4"
near-vm-errors = "0.17"
near-vm-logic = "0.17"
near-vm-runner = { version = "0.17", default-features = false, features = [ "wasmer2_vm", "wasmtime_vm" ] }
near-units = "0.2"
near-workspaces = "0.8"
near-workspaces = "0.9"
num = { version = "0.4", default-features = false, features = ["alloc"] }
postgres = "0.19"
primitive-types = { version = "0.12", default-features = false, features = ["rlp", "serde_no_std"] }
Expand Down
1 change: 0 additions & 1 deletion engine-tests-connector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ anyhow.workspace = true
byte-slice-cast.workspace = true
near-gas.workspace = true
near-sdk.workspace = true
near-units.workspace = true
near-workspaces.workspace = true
tokio = { workspace = true, features = ["macros"] }
hex.workspace = true
Expand Down
5 changes: 4 additions & 1 deletion engine-tests-connector/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ use aurora_engine_types::{
};
use byte_slice_cast::AsByteSlice;
use near_sdk::serde_json::json;
use near_sdk::{json_types::U128, serde, ONE_YOCTO};
use near_sdk::{json_types::U128, serde};
use near_workspaces::types::NearToken;
use near_workspaces::AccountId;
use std::str::FromStr;

const ONE_YOCTO: NearToken = NearToken::from_yoctonear(1);

/// Bytes for a NEAR smart contract implementing `ft_on_transfer`
fn dummy_ft_receiver_bytes() -> Vec<u8> {
let base_path = std::path::Path::new("../etc")
Expand Down
9 changes: 5 additions & 4 deletions engine-tests-connector/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use aurora_engine_types::types::{Address, Wei};
use near_sdk::serde_json::json;
use near_sdk::{json_types::U128, serde_json};
use near_workspaces::network::NetworkClient;
use near_workspaces::types::NearToken;
use near_workspaces::{result::ExecutionFinalResult, Account, AccountId, Contract, Worker};
use std::path::Path;

Expand Down Expand Up @@ -63,21 +64,21 @@ impl TestContract {
.batch(&root)
.create_account()
.add_key(sk.public_key(), AccessKey::full_access())
.transfer(near_units::parse_near!("100 N"))
.transfer(NearToken::from_near(100))
.transact()
.await?
.into_result()?;

let root_account = Account::from_secret_key(root, sk, &worker);
let eth_connector = root_account
.create_subaccount("aurora_eth_connector")
.initial_balance(near_units::parse_near!("15 N"))
.initial_balance(NearToken::from_near(15))
.transact()
.await?
.into_result()?;
let engine = root_account
.create_subaccount("eth_connector")
.initial_balance(near_units::parse_near!("15 N"))
.initial_balance(NearToken::from_near(15))
.transact()
.await?
.into_result()?;
Expand Down Expand Up @@ -204,7 +205,7 @@ impl TestContract {
Ok(self
.root_account
.create_subaccount(name)
.initial_balance(near_units::parse_near!("15 N"))
.initial_balance(NearToken::from_near(15))
.transact()
.await?
.into_result()?)
Expand Down
30 changes: 16 additions & 14 deletions engine-tests/src/tests/access_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@ use aurora_engine_types::parameters::engine::{
};
use aurora_engine_types::public_key::PublicKey;
use aurora_engine_types::types::Address;
use aurora_engine_workspace::parse_near;
use aurora_engine_workspace::types::{KeyType, SecretKey};
use aurora_engine_workspace::types::{KeyType, NearToken, SecretKey};
use std::fmt::Debug;
use std::str::FromStr;

const BALANCE: NearToken = NearToken::from_near(10);
const DEPOSIT: NearToken = NearToken::from_millinear(500);

#[tokio::test]
async fn test_add_key_manager() {
let aurora = deploy_engine().await;
let pk = PublicKey::from_str("ed25519:DcA2MzgpJbrUATQLLceocVckhhAqrkingax4oJ9kZ847").unwrap();
let relayer_key_args = RelayerKeyArgs { public_key: pk };
let manager = aurora
.root()
.create_subaccount("key_manager", parse_near!("10 N"))
.create_subaccount("key_manager", BALANCE)
.await
.unwrap();

let result = manager
.call(&aurora.id(), "add_relayer_key")
.args_json(relayer_key_args.clone())
.deposit(parse_near!("0.5 N"))
.deposit(DEPOSIT)
.max_gas()
.transact()
.await
Expand All @@ -46,7 +48,7 @@ async fn test_add_key_manager() {
.call(&aurora.id(), "add_relayer_key")
.args_json(relayer_key_args.clone())
.max_gas()
.deposit(parse_near!("0.5 N"))
.deposit(DEPOSIT)
.transact()
.await
.unwrap();
Expand All @@ -64,7 +66,7 @@ async fn test_add_key_manager() {
.call(&aurora.id(), "add_relayer_key")
.args_json(relayer_key_args)
.max_gas()
.deposit(parse_near!("0.5 N"))
.deposit(DEPOSIT)
.transact()
.await
.unwrap();
Expand All @@ -82,7 +84,7 @@ async fn test_submit_by_relayer() {

let manager = aurora
.root()
.create_subaccount("key_manager", parse_near!("10 N"))
.create_subaccount("key_manager", BALANCE)
.await
.unwrap();
let result = aurora
Expand All @@ -108,7 +110,7 @@ async fn test_submit_by_relayer() {
.call(&aurora.id(), "add_relayer_key")
.args_json(RelayerKeyArgs { public_key })
.max_gas()
.deposit(parse_near!("0.5 N"))
.deposit(DEPOSIT)
.transact()
.await
.unwrap();
Expand All @@ -131,7 +133,7 @@ async fn test_delete_relayer_key() {

let manager = aurora
.root()
.create_subaccount("key_manager", parse_near!("10 N"))
.create_subaccount("key_manager", BALANCE)
.await
.unwrap();
let result = aurora
Expand All @@ -148,7 +150,7 @@ async fn test_delete_relayer_key() {
.call(&aurora.id(), "add_relayer_key")
.args_json(RelayerKeyArgs { public_key })
.max_gas()
.deposit(parse_near!("0.5 N"))
.deposit(DEPOSIT)
.transact()
.await
.unwrap();
Expand Down Expand Up @@ -199,7 +201,7 @@ async fn test_call_not_allowed_method() {

let manager = aurora
.root()
.create_subaccount("key_manager", parse_near!("10 N"))
.create_subaccount("key_manager", BALANCE)
.await
.unwrap();
let result = aurora
Expand All @@ -216,7 +218,7 @@ async fn test_call_not_allowed_method() {
.call(&aurora.id(), "add_relayer_key")
.args_json(RelayerKeyArgs { public_key })
.max_gas()
.deposit(parse_near!("0.5 N"))
.deposit(DEPOSIT)
.transact()
.await
.unwrap();
Expand All @@ -243,7 +245,7 @@ async fn test_call_not_allowed_contract() {

let manager = aurora
.root()
.create_subaccount("key_manager", parse_near!("10 N"))
.create_subaccount("key_manager", BALANCE)
.await
.unwrap();
let result = aurora
Expand All @@ -260,7 +262,7 @@ async fn test_call_not_allowed_contract() {
.call(&aurora.id(), "add_relayer_key")
.args_json(RelayerKeyArgs { public_key })
.max_gas()
.deposit(parse_near!("0.5 N"))
.deposit(DEPOSIT)
.transact()
.await
.unwrap();
Expand Down
27 changes: 17 additions & 10 deletions engine-tests/src/tests/erc20_connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,10 @@ pub mod workspace {
use aurora_engine::proof::Proof;
use aurora_engine_types::parameters::engine::TransactionStatus;
use aurora_engine_workspace::account::Account;
use aurora_engine_workspace::types::ExecutionFinalResult;
use aurora_engine_workspace::{parse_near, EngineContract, RawContract};
use aurora_engine_workspace::types::{ExecutionFinalResult, NearToken};
use aurora_engine_workspace::{EngineContract, RawContract};

const BALANCE: NearToken = NearToken::from_near(50);
const FT_TOTAL_SUPPLY: u128 = 1_000_000;
const FT_TRANSFER_AMOUNT: u128 = 300_000;
const FT_EXIT_AMOUNT: u128 = 100_000;
Expand Down Expand Up @@ -532,7 +533,11 @@ pub mod workspace {
&aurora,
)
.await;
let total_tokens_burnt: u128 = result.outcomes().iter().map(|o| o.tokens_burnt).sum();
let total_tokens_burnt: u128 = result
.outcomes()
.iter()
.map(|o| o.tokens_burnt.as_yoctonear())
.sum();

// Check that the wnear tokens are properly unwrapped and transferred to `ft_owner`
assert_eq!(
Expand Down Expand Up @@ -578,7 +583,11 @@ pub mod workspace {
&aurora,
)
.await;
let total_tokens_burnt: u128 = result.outcomes().iter().map(|o| o.tokens_burnt).sum();
let total_tokens_burnt: u128 = result
.outcomes()
.iter()
.map(|o| o.tokens_burnt.as_yoctonear())
.sum();

// Check that there were no near tokens transferred to `ft_owner`
assert_eq!(
Expand Down Expand Up @@ -717,7 +726,7 @@ pub mod workspace {
None,
)
.max_gas()
.deposit(1)
.deposit(NearToken::from_yoctonear(1))
.transact()
.await
.unwrap();
Expand Down Expand Up @@ -761,7 +770,6 @@ pub mod workspace {
);
}

#[allow(clippy::future_not_send)]
async fn test_exit_to_near_eth_common() -> anyhow::Result<TestExitToNearEthContext> {
let aurora = deploy_engine().await;
let chain_id = aurora.get_chain_id().await?.result.as_u64();
Expand Down Expand Up @@ -808,13 +816,13 @@ pub mod workspace {
})
}

#[allow(clippy::future_not_send, clippy::cognitive_complexity)]
#[allow(clippy::cognitive_complexity)]
async fn test_exit_to_near_common() -> anyhow::Result<TestExitToNearContext> {
// 1. deploy Aurora
let aurora = deploy_engine().await;

// 2. Create account
let ft_owner = create_sub_account(&aurora.root(), "ft_owner", parse_near!("50 N")).await?;
let ft_owner = create_sub_account(&aurora.root(), "ft_owner", BALANCE).await?;
let ft_owner_address =
aurora_engine_sdk::types::near_account_to_evm_address(ft_owner.id().as_bytes());
let result = aurora
Expand Down Expand Up @@ -866,8 +874,7 @@ pub mod workspace {
);

// 5. Deploy NEP-141
let nep_141_account =
create_sub_account(&aurora.root(), FT_ACCOUNT, parse_near!("50 N")).await?;
let nep_141_account = create_sub_account(&aurora.root(), FT_ACCOUNT, BALANCE).await?;

let nep_141 = deploy_nep_141(&nep_141_account, &ft_owner, FT_TOTAL_SUPPLY, &aurora)
.await
Expand Down
Loading