Skip to content

Commit b978dae

Browse files
author
Eason
committed
fix unit tests
1 parent b667d65 commit b978dae

2 files changed

Lines changed: 34 additions & 15 deletions

File tree

core/executor/src/tests/system_script/ckb_light_client.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn test_update_first(backend: &mut MemoryBackend, executor: &CkbLightClientContr
6262
assert!(r.exit_reason.is_succeed());
6363

6464
check_root(backend, executor);
65-
check_nounce(backend, U256::one());
65+
check_nonce(backend, 1);
6666

6767
let queried_header = executor
6868
.get_header_by_block_hash(&H256::default())
@@ -85,7 +85,7 @@ fn test_update_second(backend: &mut MemoryBackend, executor: &CkbLightClientCont
8585
assert!(r.exit_reason.is_succeed());
8686

8787
check_root(backend, executor);
88-
check_nounce(backend, U256::from(2));
88+
check_nonce(backend, 2);
8989

9090
let queried_header = executor
9191
.get_header_by_block_hash(&H256::from_slice(&header.block_hash))
@@ -160,9 +160,19 @@ fn check_root(backend: &MemoryBackend, executor: &CkbLightClientContract) {
160160
);
161161
}
162162

163-
fn check_nounce(backend: &mut MemoryBackend, nounce: U256) {
164-
let ckb_account = backend.basic(CkbLightClientContract::ADDRESS);
165-
let ic_account = backend.basic(ImageCellContract::ADDRESS);
166-
assert_eq!(ckb_account.nonce, nounce);
167-
assert_eq!(ic_account.nonce, U256::zero());
163+
fn check_nonce(backend: &mut MemoryBackend, nonce: u64) {
164+
assert_eq!(
165+
backend.basic(CkbLightClientContract::ADDRESS).nonce,
166+
U256::zero()
167+
);
168+
assert_eq!(
169+
backend.basic(ImageCellContract::ADDRESS).nonce,
170+
U256::zero()
171+
);
172+
assert_eq!(
173+
backend
174+
.basic(H160::from_str("0xf000000000000000000000000000000000000000").unwrap())
175+
.nonce,
176+
nonce.into()
177+
)
168178
}

core/executor/src/tests/system_script/image_cell.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn test_update_first(backend: &mut MemoryBackend, executor: &ImageCellContract)
4343
assert!(r.exit_reason.is_succeed());
4444

4545
check_root(backend, executor);
46-
check_nounce(backend, U256::one());
46+
check_nonce(backend, 1);
4747

4848
let cell_key = CellKey::new([7u8; 32], 0x0);
4949
let get_cell = executor.get_cell(&cell_key).unwrap().unwrap();
@@ -66,7 +66,7 @@ fn test_update_second(backend: &mut MemoryBackend, executor: &ImageCellContract)
6666
assert!(r.exit_reason.is_succeed());
6767

6868
check_root(backend, executor);
69-
check_nounce(backend, U256::from(2));
69+
check_nonce(backend, 2);
7070

7171
let cell_key = CellKey::new([7u8; 32], 0x0);
7272
let get_cell = executor.get_cell(&cell_key).unwrap().unwrap();
@@ -210,10 +210,19 @@ fn prepare_outputs() -> Vec<image_cell_abi::CellInfo> {
210210
}]
211211
}
212212

213-
fn check_nounce(backend: &mut MemoryBackend, nounce: U256) {
214-
let ic_account = backend.basic(ImageCellContract::ADDRESS);
215-
let ckb_account = backend.basic(CkbLightClientContract::ADDRESS);
216-
217-
assert_eq!(ic_account.nonce, nounce);
218-
assert_eq!(ckb_account.nonce, U256::zero());
213+
fn check_nonce(backend: &mut MemoryBackend, nonce: u64) {
214+
assert_eq!(
215+
backend.basic(CkbLightClientContract::ADDRESS).nonce,
216+
U256::zero()
217+
);
218+
assert_eq!(
219+
backend.basic(ImageCellContract::ADDRESS).nonce,
220+
U256::zero()
221+
);
222+
assert_eq!(
223+
backend
224+
.basic(H160::from_str("0xf000000000000000000000000000000000000000").unwrap())
225+
.nonce,
226+
nonce.into()
227+
)
219228
}

0 commit comments

Comments
 (0)