Created
September 12, 2020 13:14
-
-
Save yatender-oktalk/aee63a1148835bcab6c017b31b644402 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ExChain.Blockchain.BlockTest do | |
@moduledoc """ | |
This module contains test related to a block | |
""" | |
use ExUnit.Case | |
alias ExChain.BlockChain.Block | |
describe "block" do | |
test "genesis is valid" do | |
assert %Block{ | |
data: "genesis data", | |
hash: "genesis-hash", | |
last_hash: "-", | |
timestamp: 1_599_909_623_805_627 | |
} == Block.genesis() | |
end | |
test "new give a new block when we pass the parameters" do | |
# setup the data | |
timestamp = DateTime.utc_now() |> DateTime.to_unix(1_000_000) | |
data = "this is new block data" | |
last_hash = "random_hash_last_block" | |
assert %Block{timestamp: ^timestamp, hash: hash, last_hash: ^last_hash, data: ^data} = | |
Block.new(timestamp, hash, last_hash, data) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment