func TestTransactionFollowsMinimumValues(t *testing.T) {
	txn := Transaction{
		SiacoinOutputs: []SiacoinOutput{{Value: NewCurrency64(1)}},
		FileContracts:  []FileContract{{Payout: NewCurrency64(1)}},
		SiafundOutputs: []SiafundOutput{{Value: NewCurrency64(1)}},
		MinerFees:      []Currency{NewCurrency64(1)},
	}
	err := txn.followsMinimumValues()
	if err != nil {
		t.Error(err)
	}
	txn.SiacoinOutputs[0].Value = ZeroCurrency
	err = txn.followsMinimumValues()
	if err != ErrZeroOutput {
		t.Error(err)
	}
	txn.SiacoinOutputs[0].Value = NewCurrency64(1)
	txn.FileContracts[0].Payout = ZeroCurrency
	err = txn.followsMinimumValues()
	if err != ErrZeroOutput {
		t.Error(err)
	}
	txn.FileContracts[0].Payout = NewCurrency64(1)
	txn.SiafundOutputs[0].Value = ZeroCurrency
	err = txn.followsMinimumValues()
	if err != ErrZeroOutput {
		t.Error(err)
	}
	txn.SiafundOutputs[0].Value = NewCurrency64(1)
	txn.MinerFees[0] = ZeroCurrency
	err = txn.followsMinimumValues()
	if err != ErrZeroMinerFee {
		t.Error(err)
	}
	txn.MinerFees[0] = NewCurrency64(1)
	txn.SiafundOutputs[0].ClaimStart = NewCurrency64(1)
	err = txn.followsMinimumValues()
	if err != ErrNonZeroClaimStart {
		t.Error(err)
	}
	txn.SiafundOutputs[0].ClaimStart = ZeroCurrency
}
TestTransactionFollowsMinimumValues probes the followsMinimumValues method
of the Transaction type.
package types
import (
	"testing"
)
func TestTransactionCorrectFileContracts(t *testing.T) {
	txn := Transaction{
		FileContracts: []FileContract{
			{
				WindowStart: 35,
				WindowEnd:   40,
				Payout:      NewCurrency64(1e6),
				ValidProofOutputs: []SiacoinOutput{
					{Value: NewCurrency64(70e3)},
					{Value: NewCurrency64(900e3)},
				},
				MissedProofOutputs: []SiacoinOutput{
					{Value: NewCurrency64(70e3)},
					{Value: NewCurrency64(900e3)},
				},
			},
		},
	}
	err := txn.correctFileContracts(30)
	if err != nil {
		t.Error(err)
	}
	err = txn.correctFileContracts(35)
	if err != ErrFileContractWindowStartViolation {
		t.Error(err)
	}
	err = txn.correctFileContracts(135)
	if err != ErrFileContractWindowStartViolation {
		t.Error(err)
	}
	txn.FileContracts[0].WindowEnd = 35
	err = txn.correctFileContracts(30)
	if err != ErrFileContractWindowEndViolation {
		t.Error(err)
	}
	txn.FileContracts[0].WindowEnd = 35
	err = txn.correctFileContracts(30)
	if err != ErrFileContractWindowEndViolation {
		t.Error(err)
	}
	txn.FileContracts[0].WindowEnd = 40
	txn.FileContracts[0].ValidProofOutputs[0].Value = NewCurrency64(69e3)
	err = txn.correctFileContracts(30)
	if err != ErrFileContractOutputSumViolation {
		t.Error(err)
	}
	txn.FileContracts[0].ValidProofOutputs[0].Value = NewCurrency64(71e3)
	err = txn.correctFileContracts(30)
	if err != ErrFileContractOutputSumViolation {
		t.Error(err)
	}
	txn.FileContracts[0].ValidProofOutputs[0].Value = NewCurrency64(70e3)
	txn.FileContracts[0].MissedProofOutputs[0].Value = NewCurrency64(69e3)
	err = txn.correctFileContracts(30)
	if err != ErrFileContractOutputSumViolation {
		t.Error(err)
	}
	txn.FileContracts[0].MissedProofOutputs[0].Value = NewCurrency64(71e3)
	err = txn.correctFileContracts(30)
	if err != ErrFileContractOutputSumViolation {
		t.Error(err)
	}
	txn.FileContracts[0].MissedProofOutputs[0].Value = NewCurrency64(70e3)
	txn.FileContracts = append(txn.FileContracts, FileContract{
		WindowStart: 35,
		WindowEnd:   40,
		Payout:      NewCurrency64(1e3),
		ValidProofOutputs: []SiacoinOutput{
			{Value: NewCurrency64(1e3)},
		},
		MissedProofOutputs: []SiacoinOutput{
			{Value: NewCurrency64(1e3)},
		},
	})
	err = txn.correctFileContracts(30)
	if err != nil {
		t.Error(err)
	}
}
func TestCorrectFileContractRevisions(t *testing.T) {
	txn := Transaction{
		FileContractRevisions: []FileContractRevision{{}},
	}
	err := txn.correctFileContractRevisions(0)
	if err != ErrFileContractWindowStartViolation {
		t.Error(err)
	}
	txn = Transaction{
		FileContractRevisions: []FileContractRevision{
			{NewWindowStart: 1},
		},
	}
	err = txn.correctFileContractRevisions(0)
	if err != ErrFileContractWindowEndViolation {
		t.Error(err)
	}
	txn.FileContractRevisions = []FileContractRevision{
		{
			NewWindowStart: 1,
			NewWindowEnd:   2,
			NewMissedProofOutputs: []SiacoinOutput{
				{Value: NewCurrency64(10)},
			},
		},
	}
	err = txn.correctFileContractRevisions(0)
	if err != ErrFileContractOutputSumViolation {
		t.Error("Expecting ErrFileContractOutputSumViolation:", err)
	}
}
func TestTransactionFitsInABlock(t *testing.T) {
	data := make([]byte, BlockSizeLimit/2)
	txn := Transaction{ArbitraryData: [][]byte{data}}
	err := txn.fitsInABlock(0)
	if err != nil {
		t.Error(err)
	}
	data = make([]byte, BlockSizeLimit)
	txn.ArbitraryData[0] = data
	err = txn.fitsInABlock(0)
	if err != ErrTransactionTooLarge {
		t.Error(err)
	}
	data = make([]byte, OakHardforkTxnSizeLimit+1)
	txn.ArbitraryData[0] = data
	err = txn.fitsInABlock(0)
	if err != nil {
		t.Error(err)
	}
	err = txn.fitsInABlock(OakHardforkBlock)
	if err != ErrTransactionTooLarge {
		t.Error(err)
	}
}