Skip to content

Instantly share code, notes, and snippets.

@yatender-oktalk
Created September 12, 2020 13:14
Show Gist options
  • Save yatender-oktalk/aee63a1148835bcab6c017b31b644402 to your computer and use it in GitHub Desktop.
Save yatender-oktalk/aee63a1148835bcab6c017b31b644402 to your computer and use it in GitHub Desktop.
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