From fc9aa0c69b11f6ec93255b984839e0c2418a63cf Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Wed, 14 Apr 2021 00:34:39 +0300 Subject: Add empty block test --- src/schema.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/schema.rs') diff --git a/src/schema.rs b/src/schema.rs index b07744a..6719722 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -92,6 +92,7 @@ pub struct Transaction { /// #[derive(Serialize, Deserialize, Debug)] pub struct Block { + #[serde(skip_serializing_if = "Vec::is_empty")] pub transaction_list: Vec, pub nonce: u32, pub timestamp: NaiveDateTime, @@ -101,6 +102,7 @@ pub struct Block { /// For prototyping and letting serde handle everything json #[derive(Serialize, Deserialize, Debug)] pub struct NakedBlock { + #[serde(skip_serializing_if = "Vec::is_empty", default)] pub transaction_list: Vec, pub nonce: u32, pub timestamp: NaiveDateTime, @@ -110,10 +112,10 @@ impl Block { /// Genesis block pub fn new() -> Block { Block { - transaction_list: vec![], + transaction_list: vec!["gradecoin_bank".to_owned()], nonce: 0, timestamp: NaiveDate::from_ymd(2021, 04, 11).and_hms(20, 45, 00), - hash: String::from(""), + hash: String::from("not_actually_mined"), } } } -- cgit v1.2.3-70-g09d2