Skip to content

Commit af4be94

Browse files
committed
allowlist: WIP Add test initialization
1 parent b9be749 commit af4be94

2 files changed

Lines changed: 200 additions & 160 deletions

File tree

Lines changed: 57 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,71 @@
55
// Copyright (c) DUSK NETWORK. All rights reserved.
66

77
use dusk_core::abi::ContractError;
8-
use dusk_core::abi::{ContractId, CONTRACT_ID_BYTES};
9-
use dusk_core::signatures::bls::{
10-
PublicKey as AccountPublicKey, SecretKey as AccountSecretKey,
8+
// use dusk_core::abi::{ContractId, CONTRACT_ID_BYTES};
9+
// use dusk_core::signatures::bls::{
10+
// PublicKey as AccountPublicKey, SecretKey as AccountSecretKey,
11+
// };
12+
// use dusk_core::transfer::data::ContractCall;
13+
// use dusk_core::transfer::MoonlightTransactionEvent;
14+
//
15+
// use rand::rngs::StdRng;
16+
// use rand::SeedableRng;
17+
//
18+
// use emt_core::token::error;
19+
// use emt_core::token::events;
20+
use emt_core::allowlist::{Address, Role};
21+
use emt_core::{
22+
Account,
23+
// AccountInfo, ZERO_ADDRESS
1124
};
12-
use dusk_core::transfer::data::ContractCall;
13-
use dusk_core::transfer::MoonlightTransactionEvent;
14-
15-
use rand::rngs::StdRng;
16-
use rand::SeedableRng;
17-
18-
use emt_core::token::error;
19-
use emt_core::token::events;
20-
use emt_core::{Account, AccountInfo, ZERO_ADDRESS};
2125

2226
pub mod instantiate;
2327
use instantiate::{
24-
TestSession, HOLDER_ID, INITIAL_BALANCE, INITIAL_HOLDER_BALANCE,
25-
INITIAL_SUPPLY,
28+
TestSession,
29+
// HOLDER_ID, INITIAL_EMT_BALANCE
2630
};
2731

2832
#[test]
2933
fn deploy() {
3034
TestSession::new();
3135
}
3236

37+
#[test]
38+
fn is_allowed() -> Result<(), ContractError> {
39+
let mut session = TestSession::new();
40+
41+
let unregistered: [u8; 32] = rand::random();
42+
let unregistered = Address::from(&unregistered);
43+
assert_eq!(session.allowlist_is_allowed(&unregistered)?.data, false);
44+
45+
let role: [u8; 32] = rand::random();
46+
let role = Role::from(&role);
47+
session.allowlist_register(&*TestSession::SK_0, unregistered, role)?;
48+
49+
session.allowlist_remove(&*TestSession::SK_0, &unregistered)?;
50+
51+
Ok(())
52+
}
53+
54+
/// Test transfer of ownership to test account.
55+
#[test]
56+
fn transfer_ownership() {
57+
let mut session = TestSession::new();
58+
let new_ownership = Account::from(*TestSession::PK_1);
59+
60+
session
61+
.allowlist_transfer_ownership(&*TestSession::SK_0, &new_ownership)
62+
.expect("Call should pass");
63+
64+
assert_eq!(
65+
session
66+
.allowlist_ownership()
67+
.expect("call should pass")
68+
.data,
69+
new_ownership
70+
);
71+
}
72+
/*
3373
#[test]
3474
fn empty_account() {
3575
let mut session = TestSession::new();
@@ -450,23 +490,9 @@ fn transfer_from() {
450490
"The account should have the transferred amount subtracted from its allowance"
451491
);
452492
}
493+
*/
453494

454-
/// Test transfer of ownership to test account.
455-
#[test]
456-
fn transfer_ownership() {
457-
let mut session = TestSession::new();
458-
let new_ownership = Account::from(*TestSession::PK_2);
459-
460-
session
461-
.call_token::<_, ()>(
462-
&*TestSession::SK_0,
463-
"transfer_ownership",
464-
&new_ownership,
465-
)
466-
.expect("Call should pass");
467-
468-
assert_eq!(session.ownership(), new_ownership);
469-
}
495+
/*
470496
471497
/// Test TransferOwnership, RenounceOwnership with wrong ownership
472498
/// and check for correct error message.
@@ -968,3 +994,4 @@ fn test_sanctions() {
968994
)
969995
.expect("Transfer should succeed again");
970996
}
997+
*/

0 commit comments

Comments
 (0)