From bfbaff9fae51cbb99933cabd30c05ae4dae1c29f Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Sun, 28 Aug 2016 17:54:36 -0500 Subject: [PATCH] integration: Add BIP9 mining tests. --- integration/bip0009_test.go | 131 ++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 integration/bip0009_test.go diff --git a/integration/bip0009_test.go b/integration/bip0009_test.go new file mode 100644 index 000000000..7de6137c0 --- /dev/null +++ b/integration/bip0009_test.go @@ -0,0 +1,131 @@ +// Copyright (c) 2016 The btcsuite developers +// Use of this source code is governed by an ISC +// license that can be found in the LICENSE file. + +// This file is ignored during the regular tests due to the following build tag. +// +build rpctest + +package integration + +import ( + "runtime" + "testing" + + "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/rpctest" +) + +// assertVersionBit gets the passed block hash from the given test harness and +// ensures its version either has the provided bit set or unset per the set +// flag. +func assertVersionBit(r *rpctest.Harness, t *testing.T, hash *chainhash.Hash, bit uint8, set bool) { + block, err := r.Node.GetBlock(hash) + if err != nil { + t.Fatalf("failed to retrieve block %v: %v", hash, err) + } + switch { + case set && block.Header.Version&(1<