From 47e1b3cf4e5990cda96e7b2e5f0d516c4c3be3e7 Mon Sep 17 00:00:00 2001 From: Ryan Henderson Date: Thu, 14 Jul 2016 10:31:10 +0200 Subject: [PATCH] treat genesis block as valid (#433) --- bigchaindb/consensus.py | 2 +- tests/db/test_bigchain_api.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bigchaindb/consensus.py b/bigchaindb/consensus.py index 3b1c2398..66313809 100644 --- a/bigchaindb/consensus.py +++ b/bigchaindb/consensus.py @@ -129,7 +129,7 @@ class BaseConsensusRules(AbstractConsensusRules): # If the operation is CREATE the transaction should have no inputs and # should be signed by a federation node - if transaction['transaction']['operation'] == 'CREATE': + if transaction['transaction']['operation'] in ('CREATE', 'GENESIS'): # TODO: for now lets assume a CREATE transaction only has one fulfillment if transaction['transaction']['fulfillments'][0]['input']: raise ValueError('A CREATE operation has no inputs') diff --git a/tests/db/test_bigchain_api.py b/tests/db/test_bigchain_api.py index a416e730..418b9983 100644 --- a/tests/db/test_bigchain_api.py +++ b/tests/db/test_bigchain_api.py @@ -259,7 +259,9 @@ class TestBigchainApi(object): genesis = list(r.table('bigchain') .filter(r.row['block_number'] == 0) .run(b.conn))[0] - assert b.get_last_voted_block() == genesis + gb = b.get_last_voted_block() + assert gb == genesis + assert b.validate_block(gb) == gb def test_get_last_voted_block_returns_the_correct_block(self, b): genesis = b.create_genesis_block()