diff --git a/CHANGELOG.md b/CHANGELOG.md index 71543f99cca..07b13688d94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Fail when decoding from storage and not all bytes consumed - [#1897](https://github.com/paritytech/ink/pull/1897) +- Make the `default_accounts` in integration test and e2e the same addresses. - [#1955](https://github.com/paritytech/ink/pull/1955) ### Added - Linter: `storage_never_freed` lint - [#1932](https://github.com/paritytech/ink/pull/1932) diff --git a/crates/env/Cargo.toml b/crates/env/Cargo.toml index 5dd9275d2a3..342ad7e24b8 100644 --- a/crates/env/Cargo.toml +++ b/crates/env/Cargo.toml @@ -53,6 +53,7 @@ schnorrkel = { version = "0.11.2", optional = true } scale-decode = { workspace = true, optional = true } scale-encode = { workspace = true, optional = true } scale-info = { workspace = true, features = ["derive"], optional = true } +sp-keyring = { workspace = true } [dev-dependencies] ink = { path = "../ink" } diff --git a/crates/env/src/engine/off_chain/test_api.rs b/crates/env/src/engine/off_chain/test_api.rs index b36c58d2252..0f86dbc3cbb 100644 --- a/crates/env/src/engine/off_chain/test_api.rs +++ b/crates/env/src/engine/off_chain/test_api.rs @@ -306,42 +306,52 @@ where instance.engine.set_callee(encoded_alice.clone()); // set up the funds for the default accounts - let substantial = 1_000_000; - let some = 1_000; + let substantial = 1_u128 << 60; instance.engine.set_balance(encoded_alice, substantial); instance .engine - .set_balance(scale::Encode::encode(&default_accounts.bob), some); + .set_balance(scale::Encode::encode(&default_accounts.bob), substantial); + instance.engine.set_balance( + scale::Encode::encode(&default_accounts.charlie), + substantial, + ); instance .engine - .set_balance(scale::Encode::encode(&default_accounts.charlie), some); + .set_balance(scale::Encode::encode(&default_accounts.dave), substantial); instance .engine - .set_balance(scale::Encode::encode(&default_accounts.django), 0); + .set_balance(scale::Encode::encode(&default_accounts.eve), substantial); instance .engine - .set_balance(scale::Encode::encode(&default_accounts.eve), 0); + .set_balance(scale::Encode::encode(&default_accounts.ferdie), substantial); instance .engine - .set_balance(scale::Encode::encode(&default_accounts.frank), 0); + .set_balance(scale::Encode::encode(&default_accounts.one), substantial); + instance + .engine + .set_balance(scale::Encode::encode(&default_accounts.two), substantial); }); f(default_accounts) } /// Returns the default accounts for testing purposes: -/// Alice, Bob, Charlie, Django, Eve and Frank. +/// Alice, Bob, Charlie, Dave, Eve, Ferdie, One and Two. pub fn default_accounts() -> DefaultAccounts where T: Environment, ::AccountId: From<[u8; 32]>, { DefaultAccounts { - alice: T::AccountId::from([0x01; 32]), - bob: T::AccountId::from([0x02; 32]), - charlie: T::AccountId::from([0x03; 32]), - django: T::AccountId::from([0x04; 32]), - eve: T::AccountId::from([0x05; 32]), - frank: T::AccountId::from([0x06; 32]), + alice: T::AccountId::from(sp_keyring::sr25519::Keyring::Alice.to_raw_public()), + bob: T::AccountId::from(sp_keyring::sr25519::Keyring::Bob.to_raw_public()), + charlie: T::AccountId::from( + sp_keyring::sr25519::Keyring::Charlie.to_raw_public(), + ), + dave: T::AccountId::from(sp_keyring::sr25519::Keyring::Dave.to_raw_public()), + eve: T::AccountId::from(sp_keyring::sr25519::Keyring::Eve.to_raw_public()), + ferdie: T::AccountId::from(sp_keyring::sr25519::Keyring::Ferdie.to_raw_public()), + one: T::AccountId::from(sp_keyring::sr25519::Keyring::One.to_raw_public()), + two: T::AccountId::from(sp_keyring::sr25519::Keyring::Two.to_raw_public()), } } @@ -356,12 +366,16 @@ where pub bob: T::AccountId, /// The predefined `CHARLIE` account holding some amounts of value. pub charlie: T::AccountId, - /// The predefined `DJANGO` account holding no value. - pub django: T::AccountId, + /// The predefined `DAVE` account holding no value. + pub dave: T::AccountId, /// The predefined `EVE` account holding no value. pub eve: T::AccountId, - /// The predefined `FRANK` account holding no value. - pub frank: T::AccountId, + /// The predefined `FERDIE` account holding no value. + pub ferdie: T::AccountId, + /// The predefined `ONE` account holding no value. + pub one: T::AccountId, + /// The predefined `TWO` account holding no value. + pub two: T::AccountId, } /// Returns the recorded emitted events in order. diff --git a/crates/ink/codegen/src/generator/trait_def/trait_registry.rs b/crates/ink/codegen/src/generator/trait_def/trait_registry.rs index 6d6471e53e3..b0fe1a25bdb 100644 --- a/crates/ink/codegen/src/generator/trait_def/trait_registry.rs +++ b/crates/ink/codegen/src/generator/trait_def/trait_registry.rs @@ -21,7 +21,9 @@ use super::TraitDefinition; use crate::{ - generator::{self,}, + generator::{ + self, + }, traits::GenerateCode, EnforcedErrors, }; diff --git a/crates/ink/ir/src/ir/attrs.rs b/crates/ink/ir/src/ir/attrs.rs index 4cd8320f434..100efa06548 100644 --- a/crates/ink/ir/src/ir/attrs.rs +++ b/crates/ink/ir/src/ir/attrs.rs @@ -32,7 +32,9 @@ use syn::{ }; use crate::{ - ast::{self,}, + ast::{ + self, + }, error::ExtError as _, ir, ir::{ diff --git a/crates/ink/tests/ui/contract/fail/constructor-input-non-codec.stderr b/crates/ink/tests/ui/contract/fail/constructor-input-non-codec.stderr index 6889d1639f9..c88919a7f2e 100644 --- a/crates/ink/tests/ui/contract/fail/constructor-input-non-codec.stderr +++ b/crates/ink/tests/ui/contract/fail/constructor-input-non-codec.stderr @@ -6,6 +6,7 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeDecode` is not satisfied | = help: the following other types implement trait `WrapperTypeDecode`: Box + sp_core::Bytes Rc Arc = note: required for `NonCodecType` to implement `ink::parity_scale_codec::Decode` @@ -26,6 +27,7 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeDecode` is not satisfied | = help: the following other types implement trait `WrapperTypeDecode`: Box + sp_core::Bytes Rc Arc = note: required for `NonCodecType` to implement `ink::parity_scale_codec::Decode` @@ -41,14 +43,14 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeEncode` is not satisfied | = help: the following other types implement trait `WrapperTypeEncode`: Box + bytes::bytes::Bytes Cow<'a, T> ink::parity_scale_codec::Ref<'a, T, U> + sp_core::Bytes Rc Arc Vec - String - &T - &mut T + and $N others = note: required for `NonCodecType` to implement `Encode` note: required by a bound in `ExecutionInput::>::push_arg` --> $WORKSPACE/crates/env/src/call/execution_input.rs diff --git a/crates/ink/tests/ui/contract/fail/constructor-return-result-non-codec-error.stderr b/crates/ink/tests/ui/contract/fail/constructor-return-result-non-codec-error.stderr index ba04fb8f656..a39e7acd6f7 100644 --- a/crates/ink/tests/ui/contract/fail/constructor-return-result-non-codec-error.stderr +++ b/crates/ink/tests/ui/contract/fail/constructor-return-result-non-codec-error.stderr @@ -22,6 +22,7 @@ error[E0277]: the trait bound `contract::Error: WrapperTypeDecode` is not satisf | = help: the following other types implement trait `WrapperTypeDecode`: Box + sp_core::Bytes Rc Arc = note: required for `contract::Error` to implement `ink::parity_scale_codec::Decode` diff --git a/crates/ink/tests/ui/contract/fail/constructor-self-receiver-03.stderr b/crates/ink/tests/ui/contract/fail/constructor-self-receiver-03.stderr index 2f261fa67ca..ee2a3794ea4 100644 --- a/crates/ink/tests/ui/contract/fail/constructor-self-receiver-03.stderr +++ b/crates/ink/tests/ui/contract/fail/constructor-self-receiver-03.stderr @@ -30,6 +30,7 @@ error[E0277]: the trait bound `&Contract: WrapperTypeDecode` is not satisfied | = help: the following other types implement trait `WrapperTypeDecode`: Box + sp_core::Bytes Rc Arc = note: required for `&Contract` to implement `ink::parity_scale_codec::Decode` diff --git a/crates/ink/tests/ui/contract/fail/message-input-non-codec.stderr b/crates/ink/tests/ui/contract/fail/message-input-non-codec.stderr index 3eff91fc43f..7b6e8089453 100644 --- a/crates/ink/tests/ui/contract/fail/message-input-non-codec.stderr +++ b/crates/ink/tests/ui/contract/fail/message-input-non-codec.stderr @@ -6,6 +6,7 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeDecode` is not satisfied | = help: the following other types implement trait `WrapperTypeDecode`: Box + sp_core::Bytes Rc Arc = note: required for `NonCodecType` to implement `ink::parity_scale_codec::Decode` @@ -26,6 +27,7 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeDecode` is not satisfied | = help: the following other types implement trait `WrapperTypeDecode`: Box + sp_core::Bytes Rc Arc = note: required for `NonCodecType` to implement `ink::parity_scale_codec::Decode` @@ -41,14 +43,14 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeEncode` is not satisfied | = help: the following other types implement trait `WrapperTypeEncode`: Box + bytes::bytes::Bytes Cow<'a, T> ink::parity_scale_codec::Ref<'a, T, U> + sp_core::Bytes Rc Arc Vec - String - &T - &mut T + and $N others = note: required for `NonCodecType` to implement `Encode` note: required by a bound in `ExecutionInput::>::push_arg` --> $WORKSPACE/crates/env/src/call/execution_input.rs diff --git a/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr b/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr index 3474db6f08c..57118427c5f 100644 --- a/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr +++ b/crates/ink/tests/ui/contract/fail/message-returns-non-codec.stderr @@ -6,14 +6,14 @@ error[E0277]: the trait bound `NonCodecType: WrapperTypeEncode` is not satisfied | = help: the following other types implement trait `WrapperTypeEncode`: Box + bytes::bytes::Bytes Cow<'a, T> ink::parity_scale_codec::Ref<'a, T, U> + sp_core::Bytes Rc Arc Vec - String - &T - &mut T + and $N others = note: required for `NonCodecType` to implement `Encode` note: required by a bound in `DispatchOutput` --> src/codegen/dispatch/type_check.rs diff --git a/crates/ink/tests/ui/storage_item/fail/packed_is_not_derived_automatically.stderr b/crates/ink/tests/ui/storage_item/fail/packed_is_not_derived_automatically.stderr index 4863fb334bc..8c057a82fb8 100644 --- a/crates/ink/tests/ui/storage_item/fail/packed_is_not_derived_automatically.stderr +++ b/crates/ink/tests/ui/storage_item/fail/packed_is_not_derived_automatically.stderr @@ -6,6 +6,7 @@ error[E0277]: the trait bound `NonPacked: WrapperTypeDecode` is not satisfied | = help: the following other types implement trait `WrapperTypeDecode`: Box + sp_core::Bytes Rc Arc = note: required for `NonPacked` to implement `ink::parity_scale_codec::Decode` @@ -24,14 +25,14 @@ error[E0277]: the trait bound `NonPacked: WrapperTypeEncode` is not satisfied | = help: the following other types implement trait `WrapperTypeEncode`: Box + bytes::bytes::Bytes Cow<'a, T> ink::parity_scale_codec::Ref<'a, T, U> + sp_core::Bytes Rc Arc Vec - String - &T - &mut T + and $N others = note: required for `NonPacked` to implement `Encode` = note: required for `NonPacked` to implement `Packed` note: required by a bound in `consume_packed` diff --git a/crates/ink/tests/ui/trait_def/fail/message_input_non_codec.stderr b/crates/ink/tests/ui/trait_def/fail/message_input_non_codec.stderr index 775914c95bc..a0a5dca8dfb 100644 --- a/crates/ink/tests/ui/trait_def/fail/message_input_non_codec.stderr +++ b/crates/ink/tests/ui/trait_def/fail/message_input_non_codec.stderr @@ -6,6 +6,7 @@ error[E0277]: the trait bound `NonCodec: WrapperTypeDecode` is not satisfied | = help: the following other types implement trait `WrapperTypeDecode`: Box + sp_core::Bytes Rc Arc = note: required for `NonCodec` to implement `ink::parity_scale_codec::Decode` @@ -29,14 +30,14 @@ error[E0277]: the trait bound `NonCodec: WrapperTypeEncode` is not satisfied | = help: the following other types implement trait `WrapperTypeEncode`: Box + bytes::bytes::Bytes Cow<'a, T> ink::parity_scale_codec::Ref<'a, T, U> + sp_core::Bytes Rc Arc Vec - String - &T - &mut T + and $N others = note: required for `NonCodec` to implement `Encode` note: required by a bound in `ExecutionInput::>::push_arg` --> $WORKSPACE/crates/env/src/call/execution_input.rs diff --git a/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr b/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr index 983b1b3b880..e6ad591645c 100644 --- a/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr +++ b/crates/ink/tests/ui/trait_def/fail/message_output_non_codec.stderr @@ -6,14 +6,14 @@ error[E0277]: the trait bound `NonCodec: WrapperTypeEncode` is not satisfied | = help: the following other types implement trait `WrapperTypeEncode`: Box + bytes::bytes::Bytes Cow<'a, T> ink::parity_scale_codec::Ref<'a, T, U> + sp_core::Bytes Rc Arc Vec - String - &T - &mut T + and $N others = note: required for `NonCodec` to implement `Encode` note: required by a bound in `DispatchOutput` --> src/codegen/dispatch/type_check.rs diff --git a/integration-tests/default-accounts/.gitignore b/integration-tests/default-accounts/.gitignore new file mode 100644 index 00000000000..bf910de10af --- /dev/null +++ b/integration-tests/default-accounts/.gitignore @@ -0,0 +1,9 @@ +# Ignore build artifacts from the local tests sub-crate. +/target/ + +# Ignore backup files creates by cargo fmt. +**/*.rs.bk + +# Remove Cargo.lock when creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock \ No newline at end of file diff --git a/integration-tests/default-accounts/Cargo.toml b/integration-tests/default-accounts/Cargo.toml new file mode 100644 index 00000000000..3b0dee5319a --- /dev/null +++ b/integration-tests/default-accounts/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "default-accounts" +version = "4.1.0" +authors = ["Parity Technologies "] +edition = "2021" +publish = false + +[dependencies] +ink = { path = "../../crates/ink", default-features = false } + +scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } +scale-info = { version = "2.5", default-features = false, features = ["derive"], optional = true } + +[dev-dependencies] +ink_e2e = { path = "../../crates/e2e" } + +[lib] +path = "lib.rs" + +[features] +default = ["std"] +std = [ + "ink/std", +] +ink-as-dependency = [] +e2e-tests = [] diff --git a/integration-tests/default-accounts/lib.rs b/integration-tests/default-accounts/lib.rs new file mode 100644 index 00000000000..fee11ddea33 --- /dev/null +++ b/integration-tests/default-accounts/lib.rs @@ -0,0 +1,128 @@ +#![cfg_attr(not(feature = "std"), no_std, no_main)] + +#[ink::contract] +mod custom_default_accounts { + + #[ink(storage)] + pub struct CustomDefaultAccounts {} + + impl CustomDefaultAccounts { + /// Creates a new Template contract. + #[ink(constructor)] + pub fn new() -> Self { + Self {} + } + + #[ink(message)] + pub fn message(&self) {} + } + + impl Default for CustomDefaultAccounts { + fn default() -> Self { + Self::new() + } + } + + #[cfg(test)] + mod tests { + use super::*; + use ink::env::test::DefaultAccounts; + use ink_e2e; + + #[ink::test] + fn test_alice_account() { + let integration_test_accounts: DefaultAccounts = + ink::env::test::default_accounts::(); + let integration_alice_account_id = integration_test_accounts.alice; + + let e2e_alice_account_id: AccountId = + ink_e2e::AccountKeyring::Alice.to_raw_public().into(); + + assert_eq!(integration_alice_account_id, e2e_alice_account_id); + } + + #[ink::test] + fn test_bob_account() { + let integration_test_accounts: DefaultAccounts = + ink::env::test::default_accounts::(); + let integration_bob_account_id = integration_test_accounts.bob; + + let e2e_bob_account_id: AccountId = + ink_e2e::AccountKeyring::Bob.to_raw_public().into(); + + assert_eq!(integration_bob_account_id, e2e_bob_account_id); + } + + #[ink::test] + fn test_charlie_account() { + let integration_test_accounts: DefaultAccounts = + ink::env::test::default_accounts::(); + let integration_charlie_account_id = integration_test_accounts.charlie; + + let e2e_charlie_account_id: AccountId = + ink_e2e::AccountKeyring::Charlie.to_raw_public().into(); + + assert_eq!(integration_charlie_account_id, e2e_charlie_account_id); + } + + #[ink::test] + fn test_dave_account() { + let integration_test_accounts: DefaultAccounts = + ink::env::test::default_accounts::(); + let integration_dave_account_id = integration_test_accounts.dave; + + let e2e_dave_account_id: AccountId = + ink_e2e::AccountKeyring::Dave.to_raw_public().into(); + + assert_eq!(integration_dave_account_id, e2e_dave_account_id); + } + + #[ink::test] + fn test_eve_account() { + let integration_test_accounts: DefaultAccounts = + ink::env::test::default_accounts::(); + let integration_eve_account_id = integration_test_accounts.eve; + + let e2e_eve_account_id: AccountId = + ink_e2e::AccountKeyring::Eve.to_raw_public().into(); + + assert_eq!(integration_eve_account_id, e2e_eve_account_id); + } + + #[ink::test] + fn test_ferdie_account() { + let integration_test_accounts: DefaultAccounts = + ink::env::test::default_accounts::(); + let integration_ferdie_account_id = integration_test_accounts.ferdie; + + let e2e_ferdie_account_id: AccountId = + ink_e2e::AccountKeyring::Ferdie.to_raw_public().into(); + + assert_eq!(integration_ferdie_account_id, e2e_ferdie_account_id); + } + + #[ink::test] + fn test_one_account() { + let integration_test_accounts: DefaultAccounts = + ink::env::test::default_accounts::(); + let integration_one_account_id = integration_test_accounts.one; + + let e2e_one_account_id: AccountId = + ink_e2e::AccountKeyring::One.to_raw_public().into(); + + assert_eq!(integration_one_account_id, e2e_one_account_id); + } + + #[ink::test] + fn test_two_account() { + let integration_test_accounts: DefaultAccounts = + ink::env::test::default_accounts::(); + let integration_two_account_id = integration_test_accounts.two; + + let e2e_two_account_id: AccountId = + ink_e2e::AccountKeyring::Two.to_raw_public().into(); + + assert_eq!(integration_two_account_id, e2e_two_account_id); + } + } +} diff --git a/integration-tests/erc20/lib.rs b/integration-tests/erc20/lib.rs index c04c7a254eb..c21cc74967b 100644 --- a/integration-tests/erc20/lib.rs +++ b/integration-tests/erc20/lib.rs @@ -273,6 +273,10 @@ mod erc20 { } } + fn alice() -> AccountId{ + ink::env::test::default_accounts::().alice + } + /// The default constructor does its job. #[ink::test] fn new_works() { @@ -286,7 +290,7 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), + Some(AccountId::from(alice())), 100, ); } @@ -301,7 +305,7 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), + Some(AccountId::from(alice())), 100, ); // Get the token total supply. @@ -318,7 +322,7 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), + Some(AccountId::from(alice())), 100, ); let accounts = @@ -349,14 +353,14 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), + Some(AccountId::from(accounts.alice)), 100, ); // Check the second transfer event relating to the actual trasfer. assert_transfer_event( &emitted_events[1], - Some(AccountId::from([0x01; 32])), - Some(AccountId::from([0x02; 32])), + Some(AccountId::from(accounts.alice)), + Some(AccountId::from(accounts.bob)), 10, ); } @@ -391,7 +395,7 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), + Some(AccountId::from(accounts.alice)), 100, ); } @@ -434,15 +438,15 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), + Some(AccountId::from(accounts.alice)), 100, ); // The second event `emitted_events[1]` is an Approve event that we skip // checking. assert_transfer_event( &emitted_events[2], - Some(AccountId::from([0x01; 32])), - Some(AccountId::from([0x05; 32])), + Some(AccountId::from(accounts.alice)), + Some(AccountId::from(accounts.eve)), 10, ); } diff --git a/integration-tests/erc721/lib.rs b/integration-tests/erc721/lib.rs index 0bc5cddb034..527236314f1 100644 --- a/integration-tests/erc721/lib.rs +++ b/integration-tests/erc721/lib.rs @@ -578,7 +578,7 @@ mod erc721 { set_caller(accounts.eve); // Eve is not an approved operator by Alice. assert_eq!( - erc721.transfer_from(accounts.alice, accounts.frank, 1), + erc721.transfer_from(accounts.alice, accounts.ferdie, 1), Err(Error::NotApproved) ); // Alice owns 1 token. diff --git a/integration-tests/multisig/lib.rs b/integration-tests/multisig/lib.rs index f79fd16db77..a8e9ac42bfa 100755 --- a/integration-tests/multisig/lib.rs +++ b/integration-tests/multisig/lib.rs @@ -768,7 +768,7 @@ mod multisig { fn set_from_no_owner() { let accounts = default_accounts(); - set_caller(accounts.django); + set_caller(accounts.dave); } fn default_accounts() -> test::DefaultAccounts { @@ -782,6 +782,7 @@ mod multisig { let accounts = default_accounts(); let owners = vec![accounts.alice, accounts.bob, accounts.eve]; + println!("{:?}", owners); Multisig::new(2, owners) } @@ -802,7 +803,8 @@ mod multisig { #[ink::test] fn construction_works() { let accounts = default_accounts(); - let owners = [accounts.alice, accounts.bob, accounts.eve]; + let mut owners = [accounts.alice, accounts.bob, accounts.eve]; + owners.sort_unstable(); let contract = build_contract(); assert_eq!(contract.owners.len(), 3); @@ -812,8 +814,8 @@ mod multisig { assert!(contract.is_owner.contains(accounts.bob)); assert!(contract.is_owner.contains(accounts.eve)); assert!(!contract.is_owner.contains(accounts.charlie)); - assert!(!contract.is_owner.contains(accounts.django)); - assert!(!contract.is_owner.contains(accounts.frank)); + assert!(!contract.is_owner.contains(accounts.dave)); + assert!(!contract.is_owner.contains(accounts.ferdie)); assert_eq!(contract.transaction_list.transactions.len(), 0); } @@ -843,9 +845,9 @@ mod multisig { let mut contract = build_contract(); set_from_wallet(); let owners = contract.owners.len(); - contract.add_owner(accounts.frank); + contract.add_owner(accounts.ferdie); assert_eq!(contract.owners.len(), owners + 1); - assert!(contract.is_owner.contains(accounts.frank)); + assert!(contract.is_owner.contains(accounts.ferdie)); assert_eq!(test::recorded_events().count(), 1); } @@ -864,7 +866,7 @@ mod multisig { let accounts = default_accounts(); let mut contract = build_contract(); set_from_owner(); - contract.add_owner(accounts.frank); + contract.add_owner(accounts.ferdie); } #[ink::test] @@ -885,7 +887,7 @@ mod multisig { let accounts = default_accounts(); let mut contract = build_contract(); set_from_wallet(); - contract.remove_owner(accounts.django); + contract.remove_owner(accounts.dave); } #[ink::test] @@ -903,10 +905,10 @@ mod multisig { let mut contract = build_contract(); set_from_wallet(); let owners = contract.owners.len(); - contract.replace_owner(accounts.alice, accounts.django); + contract.replace_owner(accounts.alice, accounts.dave); assert_eq!(contract.owners.len(), owners); assert!(!contract.is_owner.contains(accounts.alice)); - assert!(contract.is_owner.contains(accounts.django)); + assert!(contract.is_owner.contains(accounts.dave)); assert_eq!(test::recorded_events().count(), 2); } @@ -925,7 +927,7 @@ mod multisig { let accounts = default_accounts(); let mut contract = build_contract(); set_from_wallet(); - contract.replace_owner(accounts.django, accounts.frank); + contract.replace_owner(accounts.dave, accounts.ferdie); } #[ink::test] @@ -934,7 +936,7 @@ mod multisig { let accounts = default_accounts(); let mut contract = build_contract(); set_from_owner(); - contract.replace_owner(accounts.alice, accounts.django); + contract.replace_owner(accounts.alice, accounts.dave); } #[ink::test] @@ -1087,7 +1089,7 @@ mod multisig { fn revoke_transaction_no_owner_fail() { let mut contract = submit_transaction(); let accounts = default_accounts(); - set_caller(accounts.django); + set_caller(accounts.dave); contract.revoke_confirmation(0); } diff --git a/integration-tests/trait-erc20/lib.rs b/integration-tests/trait-erc20/lib.rs index 56c9c739751..4faf4a74006 100644 --- a/integration-tests/trait-erc20/lib.rs +++ b/integration-tests/trait-erc20/lib.rs @@ -333,6 +333,10 @@ mod erc20 { } } + fn alice() -> AccountId{ + ink::env::test::default_accounts::().alice + } + /// The default constructor does its job. #[ink::test] fn new_works() { @@ -350,7 +354,7 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), + Some(AccountId::from(alice())), 100, ); } @@ -366,7 +370,7 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), + Some(AccountId::from(alice())), 100, ); // Get the token total supply. @@ -384,7 +388,7 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), + Some(AccountId::from(alice())), 100, ); let accounts = @@ -416,14 +420,14 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), + Some(AccountId::from(accounts.alice)), 100, ); // Check the second transfer event relating to the actual trasfer. assert_transfer_event( &emitted_events[1], - Some(AccountId::from([0x01; 32])), - Some(AccountId::from([0x02; 32])), + Some(AccountId::from(accounts.alice)), + Some(AccountId::from(accounts.bob)), 10, ); } @@ -456,7 +460,7 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), + Some(AccountId::from(accounts.alice)), 100, ); } @@ -498,15 +502,15 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), + Some(AccountId::from(accounts.alice)), 100, ); // The second event `emitted_events[1]` is an Approve event that we skip // checking. assert_transfer_event( &emitted_events[2], - Some(AccountId::from([0x01; 32])), - Some(AccountId::from([0x05; 32])), + Some(AccountId::from(accounts.alice)), + Some(AccountId::from(accounts.eve)), 10, ); }