|
|
@ -1,7 +1,7 @@ |
|
|
|
package blockchain |
|
|
|
package blockchain |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"reflect" |
|
|
|
"testing" |
|
|
|
"testing" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -15,15 +15,7 @@ func TestBlockSerialize(t *testing.T) { |
|
|
|
serializedValue := block.Serialize() |
|
|
|
serializedValue := block.Serialize() |
|
|
|
deserializedBlock := DeserializeBlock(serializedValue) |
|
|
|
deserializedBlock := DeserializeBlock(serializedValue) |
|
|
|
|
|
|
|
|
|
|
|
if block.Timestamp != deserializedBlock.Timestamp { |
|
|
|
if !reflect.DeepEqual(block, deserializedBlock) { |
|
|
|
t.Errorf("Serialize or Deserialize incorrect at TimeStamp.") |
|
|
|
t.Errorf("Original block and the deserialized block not equal.") |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if bytes.Compare(block.PrevBlockHash[:], deserializedBlock.PrevBlockHash[:]) != 0 { |
|
|
|
|
|
|
|
t.Errorf("Serialize or Deserialize incorrect at PrevBlockHash.") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if bytes.Compare(block.Hash[:], deserializedBlock.Hash[:]) != 0 { |
|
|
|
|
|
|
|
t.Errorf("Serialize or Deserialize incorrect at Hash.") |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|