func TestRuleError(t *testing.T) {
	tests := []struct {
		in   blockchain.RuleError
		want string
	}{
		{
			blockchain.RuleError{Description: "duplicate block"},
			"duplicate block",
		},
		{
			blockchain.RuleError{Description: "human-readable error"},
			"human-readable error",
		},
	}
	t.Logf("Running %d tests", len(tests))
	for i, test := range tests {
		result := test.in.Error()
		if result != test.want {
			t.Errorf("Error #%d\n got: %s want: %s", i, result,
				test.want)
			continue
		}
	}
}
TestRuleError tests the error output for the RuleError type.
package blockchain_test
import (
	"testing"
	"github.com/HcashOrg/hcashd/blockchain"
)
func TestErrorCodeStringer(t *testing.T) {
	tests := []struct {
		in   blockchain.ErrorCode
		want string
	}{
		{blockchain.ErrDuplicateBlock, "ErrDuplicateBlock"},
		{blockchain.ErrBlockTooBig, "ErrBlockTooBig"},
		{blockchain.ErrBlockVersionTooOld, "ErrBlockVersionTooOld"},
		{blockchain.ErrInvalidTime, "ErrInvalidTime"},
		{blockchain.ErrTimeTooOld, "ErrTimeTooOld"},
		{blockchain.ErrTimeTooNew, "ErrTimeTooNew"},
		{blockchain.ErrDifficultyTooLow, "ErrDifficultyTooLow"},
		{blockchain.ErrUnexpectedDifficulty, "ErrUnexpectedDifficulty"},
		{blockchain.ErrHighHash, "ErrHighHash"},
		{blockchain.ErrBadMerkleRoot, "ErrBadMerkleRoot"},
		{blockchain.ErrBadCheckpoint, "ErrBadCheckpoint"},
		{blockchain.ErrForkTooOld, "ErrForkTooOld"},
		{blockchain.ErrCheckpointTimeTooOld, "ErrCheckpointTimeTooOld"},
		{blockchain.ErrNoTransactions, "ErrNoTransactions"},
		{blockchain.ErrTooManyTransactions, "ErrTooManyTransactions"},
		{blockchain.ErrNoTxInputs, "ErrNoTxInputs"},
		{blockchain.ErrNoTxOutputs, "ErrNoTxOutputs"},
		{blockchain.ErrTxTooBig, "ErrTxTooBig"},
		{blockchain.ErrBadTxOutValue, "ErrBadTxOutValue"},
		{blockchain.ErrDuplicateTxInputs, "ErrDuplicateTxInputs"},
		{blockchain.ErrBadTxInput, "ErrBadTxInput"},
		{blockchain.ErrBadCheckpoint, "ErrBadCheckpoint"},
		{blockchain.ErrMissingTx, "ErrMissingTx"},
		{blockchain.ErrUnfinalizedTx, "ErrUnfinalizedTx"},
		{blockchain.ErrDuplicateTx, "ErrDuplicateTx"},
		{blockchain.ErrOverwriteTx, "ErrOverwriteTx"},
		{blockchain.ErrImmatureSpend, "ErrImmatureSpend"},
		{blockchain.ErrDoubleSpend, "ErrDoubleSpend"},
		{blockchain.ErrSpendTooHigh, "ErrSpendTooHigh"},
		{blockchain.ErrBadFees, "ErrBadFees"},
		{blockchain.ErrTooManySigOps, "ErrTooManySigOps"},
		{blockchain.ErrFirstTxNotCoinbase, "ErrFirstTxNotCoinbase"},
		{blockchain.ErrMultipleCoinbases, "ErrMultipleCoinbases"},
		{blockchain.ErrBadCoinbaseScriptLen, "ErrBadCoinbaseScriptLen"},
		{blockchain.ErrBadCoinbaseValue, "ErrBadCoinbaseValue"},
		{blockchain.ErrScriptMalformed, "ErrScriptMalformed"},
		{blockchain.ErrScriptValidation, "ErrScriptValidation"},
		{0xffff, "Unknown ErrorCode (65535)"},
	}
	t.Logf("Running %d tests", len(tests))
	for i, test := range tests {
		result := test.in.String()
		if result != test.want {
			t.Errorf("String #%d\n got: %s want: %s", i, result,
				test.want)
			continue
		}
	}
}