Unverified Commit 7cf84eaf authored by Michael Müller's avatar Michael Müller Committed by GitHub
Browse files

Use `#[ink::test]` instead of `#[test]` (#744)

* Use `#[ink::test]` instead of `#[test]`

* Import `ink_lang`

* Apply cargo fmt
parent 1dff8779
Pipeline #132285 passed with stages
in 41 minutes and 42 seconds
......@@ -147,8 +147,9 @@ mod flipper {
#[cfg(test)]
mod tests {
use super::*;
use ink_lang as ink;
#[test]
#[ink::test]
fn it_works() {
let mut flipper = Flipper::new(false);
assert_eq!(flipper.get(), false);
......
......@@ -32,8 +32,9 @@ mod flipper {
#[cfg(test)]
mod tests {
use super::*;
use ink_lang as ink;
#[test]
#[ink::test]
fn it_works() {
let mut flipper = Flipper::new(false);
assert_eq!(flipper.get(), false);
......
......@@ -52,14 +52,15 @@ pub mod flipper {
#[cfg(test)]
mod tests {
use super::*;
use ink_lang as ink;
#[test]
#[ink::test]
fn default_works() {
let flipper = Flipper::default();
assert_eq!(flipper.get(), false);
}
#[test]
#[ink::test]
fn it_works() {
let mut flipper = Flipper::new(false);
assert_eq!(flipper.get(), false);
......
......@@ -48,14 +48,15 @@ mod incrementer {
#[cfg(test)]
mod tests {
use super::*;
use ink_lang as ink;
#[test]
#[ink::test]
fn default_works() {
let contract = Incrementer::default();
assert_eq!(contract.get(), 0);
}
#[test]
#[ink::test]
fn it_works() {
let mut contract = Incrementer::new(42);
assert_eq!(contract.get(), 42);
......
......@@ -670,6 +670,7 @@ mod multisig_plain {
call,
test,
};
use ink_lang as ink;
type Accounts = test::DefaultAccounts<Environment>;
const WALLET: [u8; 32] = [7; 32];
......@@ -737,7 +738,7 @@ mod multisig_plain {
contract
}
#[test]
#[ink::test]
fn construction_works() {
let accounts = default_accounts();
let owners = ink_prelude::vec![accounts.alice, accounts.bob, accounts.eve];
......@@ -757,27 +758,27 @@ mod multisig_plain {
assert_eq!(contract.transactions.len(), 0);
}
#[test]
#[ink::test]
#[should_panic]
fn empty_owner_construction_fails() {
MultisigPlain::new(0, vec![]);
}
#[test]
#[ink::test]
#[should_panic]
fn zero_requirement_construction_fails() {
let accounts = default_accounts();
MultisigPlain::new(0, vec![accounts.alice, accounts.bob]);
}
#[test]
#[ink::test]
#[should_panic]
fn too_large_requirement_construction_fails() {
let accounts = default_accounts();
MultisigPlain::new(3, vec![accounts.alice, accounts.bob]);
}
#[test]
#[ink::test]
fn add_owner_works() {
let accounts = default_accounts();
let mut contract = build_contract();
......@@ -789,7 +790,7 @@ mod multisig_plain {
assert_eq!(test::recorded_events().count(), 1);
}
#[test]
#[ink::test]
#[should_panic]
fn add_existing_owner_fails() {
let accounts = default_accounts();
......@@ -798,7 +799,7 @@ mod multisig_plain {
contract.add_owner(accounts.bob);
}
#[test]
#[ink::test]
#[should_panic]
fn add_owner_permission_denied() {
let accounts = default_accounts();
......@@ -807,7 +808,7 @@ mod multisig_plain {
contract.add_owner(accounts.frank);
}
#[test]
#[ink::test]
fn remove_owner_works() {
let accounts = default_accounts();
let mut contract = build_contract();
......@@ -819,7 +820,7 @@ mod multisig_plain {
assert_eq!(test::recorded_events().count(), 1);
}
#[test]
#[ink::test]
#[should_panic]
fn remove_owner_nonexisting_fails() {
let accounts = default_accounts();
......@@ -828,7 +829,7 @@ mod multisig_plain {
contract.remove_owner(accounts.django);
}
#[test]
#[ink::test]
#[should_panic]
fn remove_owner_permission_denied() {
let accounts = default_accounts();
......@@ -837,7 +838,7 @@ mod multisig_plain {
contract.remove_owner(accounts.alice);
}
#[test]
#[ink::test]
fn replace_owner_works() {
let accounts = default_accounts();
let mut contract = build_contract();
......@@ -850,7 +851,7 @@ mod multisig_plain {
assert_eq!(test::recorded_events().count(), 2);
}
#[test]
#[ink::test]
#[should_panic]
fn replace_owner_existing_fails() {
let accounts = default_accounts();
......@@ -859,7 +860,7 @@ mod multisig_plain {
contract.replace_owner(accounts.alice, accounts.bob);
}
#[test]
#[ink::test]
#[should_panic]
fn replace_owner_nonexisting_fails() {
let accounts = default_accounts();
......@@ -868,7 +869,7 @@ mod multisig_plain {
contract.replace_owner(accounts.django, accounts.frank);
}
#[test]
#[ink::test]
#[should_panic]
fn replace_owner_permission_denied() {
let accounts = default_accounts();
......@@ -877,7 +878,7 @@ mod multisig_plain {
contract.replace_owner(accounts.alice, accounts.django);
}
#[test]
#[ink::test]
fn change_requirement_works() {
let mut contract = build_contract();
assert_eq!(*contract.requirement, 2);
......@@ -887,7 +888,7 @@ mod multisig_plain {
assert_eq!(test::recorded_events().count(), 1);
}
#[test]
#[ink::test]
#[should_panic]
fn change_requirement_too_high() {
let mut contract = build_contract();
......@@ -895,7 +896,7 @@ mod multisig_plain {
contract.change_requirement(4);
}
#[test]
#[ink::test]
#[should_panic]
fn change_requirement_zero_fails() {
let mut contract = build_contract();
......@@ -903,12 +904,12 @@ mod multisig_plain {
contract.change_requirement(0);
}
#[test]
#[ink::test]
fn submit_transaction_works() {
submit_transaction();
}
#[test]
#[ink::test]
#[should_panic]
fn submit_transaction_noowner_fails() {
let mut contract = build_contract();
......@@ -916,7 +917,7 @@ mod multisig_plain {
contract.submit_transaction(Transaction::change_requirement(1));
}
#[test]
#[ink::test]
#[should_panic]
fn submit_transaction_wallet_fails() {
let mut contract = build_contract();
......@@ -924,7 +925,7 @@ mod multisig_plain {
contract.submit_transaction(Transaction::change_requirement(1));
}
#[test]
#[ink::test]
fn cancel_transaction_works() {
let mut contract = submit_transaction();
set_from_wallet();
......@@ -933,7 +934,7 @@ mod multisig_plain {
assert_eq!(test::recorded_events().count(), 3);
}
#[test]
#[ink::test]
fn cancel_transaction_nonexisting() {
let mut contract = submit_transaction();
set_from_wallet();
......@@ -942,14 +943,14 @@ mod multisig_plain {
assert_eq!(test::recorded_events().count(), 2);
}
#[test]
#[ink::test]
#[should_panic]
fn cancel_transaction_no_permission() {
let mut contract = submit_transaction();
contract.cancel_transaction(0);
}
#[test]
#[ink::test]
fn confirm_transaction_works() {
let mut contract = submit_transaction();
let accounts = default_accounts();
......@@ -961,7 +962,7 @@ mod multisig_plain {
assert_eq!(*contract.confirmation_count.get(&0).unwrap(), 2);
}
#[test]
#[ink::test]
fn revoke_confirmations() {
// given
let mut contract = submit_transaction();
......@@ -983,7 +984,7 @@ mod multisig_plain {
assert_eq!(*contract.confirmation_count.get(&0).unwrap(), 1);
}
#[test]
#[ink::test]
fn confirm_transaction_already_confirmed() {
let mut contract = submit_transaction();
let accounts = default_accounts();
......@@ -995,7 +996,7 @@ mod multisig_plain {
assert_eq!(*contract.confirmation_count.get(&0).unwrap(), 1);
}
#[test]
#[ink::test]
#[should_panic]
fn confirm_transaction_noowner_fail() {
let mut contract = submit_transaction();
......@@ -1003,7 +1004,7 @@ mod multisig_plain {
contract.confirm_transaction(0);
}
#[test]
#[ink::test]
fn revoke_transaction_works() {
let mut contract = submit_transaction();
let accounts = default_accounts();
......@@ -1015,7 +1016,7 @@ mod multisig_plain {
assert_eq!(*contract.confirmation_count.get(&0).unwrap(), 0);
}
#[test]
#[ink::test]
fn revoke_transaction_no_confirmer() {
let mut contract = submit_transaction();
let accounts = default_accounts();
......@@ -1027,7 +1028,7 @@ mod multisig_plain {
assert_eq!(*contract.confirmation_count.get(&0).unwrap(), 1);
}
#[test]
#[ink::test]
#[should_panic]
fn revoke_transaction_noowner_fail() {
let mut contract = submit_transaction();
......@@ -1036,7 +1037,7 @@ mod multisig_plain {
contract.revoke_confirmation(0);
}
#[test]
#[ink::test]
fn execute_transaction_works() {
// Execution of calls is currently unsupported in off-chain test.
// Calling execute_transaction panics in any case.
......
......@@ -68,14 +68,15 @@ pub mod flipper {
#[cfg(test)]
mod tests {
use super::*;
use ink_lang as ink;
#[test]
#[ink::test]
fn default_works() {
let flipper = Flipper::default();
assert_eq!(flipper.get(), false);
}
#[test]
#[ink::test]
fn it_works() {
let mut flipper = Flipper::new(false);
// Can call using universal call syntax using the trait.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment