Skip to content

Commit

Permalink
fix storage test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jackzhhuang committed Aug 7, 2024
1 parent 1ed2e1d commit 81ec70e
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions storage/src/tests/test_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ fn test_block() {
.unwrap();
let dt = Local::now();

let block_body1 = BlockBody::new(vec![SignedUserTransaction::mock()], None);
let block_header1 = BlockHeader::new(
HashValue::random(),
dt.timestamp_nanos() as u64,
Expand All @@ -42,7 +43,7 @@ fn test_block() {
HashValue::zero(),
0,
U256::zero(),
HashValue::random(),
block_body1.hash(),
ChainId::test(),
0,
BlockHeaderExtra::new([0u8; 4]),
Expand All @@ -63,7 +64,6 @@ fn test_block() {
.unwrap()
.unwrap()
);
let block_body1 = BlockBody::new(vec![SignedUserTransaction::mock()], None);
storage
.block_storage
.save_body(block_id, block_body1.clone())
Expand Down Expand Up @@ -94,17 +94,18 @@ fn test_block_number() {
.unwrap();
let dt = Local::now();

let block_body1 = BlockBody::new(vec![SignedUserTransaction::mock()], None);
let block_header1 = BlockHeader::new(
HashValue::random(),
dt.timestamp_nanos() as u64,
0,
rand::random(),
AccountAddress::random(),
HashValue::zero(),
HashValue::random(),
HashValue::zero(),
0,
U256::zero(),
HashValue::random(),
block_body1.hash(),
ChainId::test(),
0,
BlockHeaderExtra::new([0u8; 4]),
Expand All @@ -125,7 +126,6 @@ fn test_block_number() {
.unwrap(),
block_header1
);
let block_body1 = BlockBody::new(vec![SignedUserTransaction::mock()], None);
storage
.block_storage
.save_body(block_id, block_body1.clone())
Expand All @@ -144,6 +144,7 @@ fn test_block_number() {
#[test]
fn test_old_failed_block_decode() {
let dt = Local::now();
let block_body = BlockBody::new(vec![SignedUserTransaction::mock()], None);
let block_header = BlockHeader::new(
HashValue::random(),
dt.timestamp_nanos() as u64,
Expand All @@ -154,15 +155,14 @@ fn test_old_failed_block_decode() {
HashValue::zero(),
0,
U256::zero(),
HashValue::random(),
block_body.hash(),
ChainId::test(),
0,
BlockHeaderExtra::new([0u8; 4]),
vec![],
rand::random(),
HashValue::random(),
);
let block_body = BlockBody::new(vec![SignedUserTransaction::mock()], None);

let block = Block::new(block_header, block_body);

Expand All @@ -183,6 +183,8 @@ fn test_save_failed_block() {
.unwrap();
let dt = Local::now();

let block_body = BlockBody::new(vec![SignedUserTransaction::mock()], None);

let block_header = BlockHeader::new(
HashValue::random(),
dt.timestamp_nanos() as u64,
Expand All @@ -193,7 +195,7 @@ fn test_save_failed_block() {
HashValue::zero(),
0,
U256::zero(),
HashValue::random(),
block_body.hash(),
ChainId::test(),
0,
BlockHeaderExtra::new([0u8; 4]),
Expand All @@ -202,8 +204,6 @@ fn test_save_failed_block() {
HashValue::random(),
);

let block_body = BlockBody::new(vec![SignedUserTransaction::mock()], None);

let block = Block::new(block_header, block_body);

storage
Expand Down Expand Up @@ -246,6 +246,7 @@ fn test_save_failed_block() {

fn new_dag_sync_block(children: Vec<HashValue>) -> anyhow::Result<DagSyncBlock> {
let dt = Local::now();
let block_body = BlockBody::new(vec![SignedUserTransaction::mock()], None);
let block_header = BlockHeader::new(
HashValue::random(),
dt.timestamp_nanos() as u64,
Expand All @@ -256,7 +257,7 @@ fn new_dag_sync_block(children: Vec<HashValue>) -> anyhow::Result<DagSyncBlock>
HashValue::zero(),
0,
U256::zero(),
HashValue::random(),
block_body.hash(),
ChainId::test(),
0,
BlockHeaderExtra::new([0u8; 4]),
Expand All @@ -265,8 +266,6 @@ fn new_dag_sync_block(children: Vec<HashValue>) -> anyhow::Result<DagSyncBlock>
HashValue::random(),
);

let block_body = BlockBody::new(vec![SignedUserTransaction::mock()], None);

let block = Block::new(block_header, block_body);

anyhow::Ok(DagSyncBlock { block, children })
Expand Down

0 comments on commit 81ec70e

Please sign in to comment.