}
}
+// TestCoinbase test the coinbase transaction is valid (txtest#1016)
func TestCoinbase(t *testing.T) {
cp, _ := vmutil.DefaultCoinbaseProgram()
retire, _ := vmutil.RetireProgram([]byte{})
}
+// TestTimeRange test the checkTimeRange function (txtest#1004)
func TestTimeRange(t *testing.T) {
cases := []struct {
timeRange uint64
func TestStandardTx(t *testing.T) {
fixture := sample(t, nil)
tx := types.NewTx(*fixture.tx).Tx
-
+
cases := []struct {
desc string
f func()
}
}
+func TestValidateTxVersion(t *testing.T) {
+ cases := []struct {
+ desc string
+ block *bc.Block
+ err error
+ }{
+ {
+ desc: "tx version greater than 1 (txtest#1001)",
+ block: &bc.Block{
+ BlockHeader: &bc.BlockHeader{Version: 1},
+ Transactions: []*bc.Tx{
+ &bc.Tx{TxHeader: &bc.TxHeader{Version: 2}},
+ },
+ },
+ err: ErrTxVersion,
+ },
+ {
+ desc: "tx version equals 0 (txtest#1002)",
+ block: &bc.Block{
+ BlockHeader: &bc.BlockHeader{Version: 1},
+ Transactions: []*bc.Tx{
+ &bc.Tx{TxHeader: &bc.TxHeader{Version: 0}},
+ },
+ },
+ err: ErrTxVersion,
+ },
+ {
+ desc: "tx version equals max uint64 (txtest#1003)",
+ block: &bc.Block{
+ BlockHeader: &bc.BlockHeader{Version: 1},
+ Transactions: []*bc.Tx{
+ &bc.Tx{TxHeader: &bc.TxHeader{Version: math.MaxUint64}},
+ },
+ },
+ err: ErrTxVersion,
+ },
+ }
+
+ for i, c := range cases {
+ if _, err := ValidateTx(c.block.Transactions[0], c.block); rootErr(err) != c.err {
+ t.Errorf("case #%d (%s) got error %t, want %t", i, c.desc, err, c.err)
+ }
+ }
+}
+
// A txFixture is returned by sample (below) to produce a sample
// transaction, which takes a separate, optional _input_ txFixture to
// affect the transaction that's built. The components of the