diff --git a/persist/sqlite/consensus_test.go b/persist/sqlite/consensus_test.go index 6c12eff8..e1235629 100644 --- a/persist/sqlite/consensus_test.go +++ b/persist/sqlite/consensus_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + "go.sia.tech/core/consensus" "go.sia.tech/core/types" "go.sia.tech/coreutils" "go.sia.tech/coreutils/chain" @@ -16,7 +17,7 @@ import ( "go.uber.org/zap/zaptest" ) -func syncDB(t *testing.T, db *sqlite.Store, cm *chain.Manager) { +func syncDB(t *testing.T, db explorer.Store, cm *chain.Manager) { index, err := db.Tip() if err != nil && !errors.Is(err, explorer.ErrNoTip) { t.Fatal(err) @@ -40,6 +41,44 @@ func syncDB(t *testing.T, db *sqlite.Store, cm *chain.Manager) { } } +func newStore(t *testing.T, v2 bool, f func(*consensus.Network, types.Block)) (*consensus.Network, types.Block, *chain.Manager, explorer.Store) { + log := zaptest.NewLogger(t) + dir := t.TempDir() + db, err := sqlite.OpenDatabase(filepath.Join(dir, "explored.sqlite3"), log.Named("sqlite3")) + if err != nil { + t.Fatal(err) + } + + bdb, err := coreutils.OpenBoltChainDB(filepath.Join(dir, "consensus.db")) + if err != nil { + t.Fatal(err) + } + + var network *consensus.Network + var genesisBlock types.Block + if v2 { + network, genesisBlock = ctestutil.V2Network() + } else { + network, genesisBlock = ctestutil.Network() + } + if f != nil { + f(network, genesisBlock) + } + + store, genesisState, err := chain.NewDBStore(bdb, network, genesisBlock) + if err != nil { + t.Fatal(err) + } + cm := chain.NewManager(store, genesisState) + syncDB(t, db, cm) + + t.Cleanup(func() { + db.Close() + bdb.Close() + }) + return network, genesisBlock, cm, db +} + // CheckMetrics checks the that the metrics from the DB match what we expect. func CheckMetrics(t *testing.T, db explorer.Store, cm *chain.Manager, expected explorer.Metrics) { t.Helper() @@ -94,28 +133,7 @@ func CheckFCRevisions(t *testing.T, confirmationIndex types.ChainIndex, confirma } func TestBalance(t *testing.T) { - log := zaptest.NewLogger(t) - dir := t.TempDir() - db, err := sqlite.OpenDatabase(filepath.Join(dir, "explored.sqlite3"), log.Named("sqlite3")) - if err != nil { - t.Fatal(err) - } - defer db.Close() - - bdb, err := coreutils.OpenBoltChainDB(filepath.Join(dir, "consensus.db")) - if err != nil { - t.Fatal(err) - } - defer bdb.Close() - - network, genesisBlock := ctestutil.Network() - - store, genesisState, err := chain.NewDBStore(bdb, network, genesisBlock) - if err != nil { - t.Fatal(err) - } - - cm := chain.NewManager(store, genesisState) + _, _, cm, db := newStore(t, false, nil) // Generate three addresses: addr1, addr2, addr3 pk1 := types.GeneratePrivateKey() @@ -198,20 +216,6 @@ func TestBalance(t *testing.T) { } func TestSiafundBalance(t *testing.T) { - log := zaptest.NewLogger(t) - dir := t.TempDir() - db, err := sqlite.OpenDatabase(filepath.Join(dir, "explored.sqlite3"), log.Named("sqlite3")) - if err != nil { - t.Fatal(err) - } - defer db.Close() - - bdb, err := coreutils.OpenBoltChainDB(filepath.Join(dir, "consensus.db")) - if err != nil { - t.Fatal(err) - } - defer bdb.Close() - // Generate three addresses: addr1, addr2, addr3 pk1 := types.GeneratePrivateKey() addr1 := types.StandardUnlockHash(pk1.PublicKey()) @@ -222,17 +226,11 @@ func TestSiafundBalance(t *testing.T) { pk3 := types.GeneratePrivateKey() addr3 := types.StandardUnlockHash(pk3.PublicKey()) - network, genesisBlock := ctestutil.Network() - genesisBlock.Transactions[0].SiafundOutputs[0].Address = addr1 + _, genesisBlock, cm, db := newStore(t, false, func(network *consensus.Network, genesisBlock types.Block) { + genesisBlock.Transactions[0].SiafundOutputs[0].Address = addr1 + }) giftSF := genesisBlock.Transactions[0].SiafundOutputs[0].Value - store, genesisState, err := chain.NewDBStore(bdb, network, genesisBlock) - if err != nil { - t.Fatal(err) - } - - cm := chain.NewManager(store, genesisState) - // Send all of the payout except 100 SF to addr2 unlockConditions := types.StandardUnlockConditions(pk1.PublicKey()) parentTxn := types.Transaction{ @@ -276,20 +274,6 @@ func TestSiafundBalance(t *testing.T) { } func TestSendTransactions(t *testing.T) { - log := zaptest.NewLogger(t) - dir := t.TempDir() - db, err := sqlite.OpenDatabase(filepath.Join(dir, "explored.sqlite3"), log.Named("sqlite3")) - if err != nil { - t.Fatal(err) - } - defer db.Close() - - bdb, err := coreutils.OpenBoltChainDB(filepath.Join(dir, "consensus.db")) - if err != nil { - t.Fatal(err) - } - defer bdb.Close() - // Generate three addresses: addr1, addr2, addr3 pk1 := types.GeneratePrivateKey() addr1 := types.StandardUnlockHash(pk1.PublicKey()) @@ -300,17 +284,11 @@ func TestSendTransactions(t *testing.T) { pk3 := types.GeneratePrivateKey() addr3 := types.StandardUnlockHash(pk3.PublicKey()) - network, genesisBlock := ctestutil.Network() - genesisBlock.Transactions[0].SiafundOutputs[0].Address = addr1 + _, genesisBlock, cm, db := newStore(t, false, func(network *consensus.Network, genesisBlock types.Block) { + genesisBlock.Transactions[0].SiafundOutputs[0].Address = addr1 + }) giftSF := genesisBlock.Transactions[0].SiafundOutputs[0].Value - store, genesisState, err := chain.NewDBStore(bdb, network, genesisBlock) - if err != nil { - t.Fatal(err) - } - - cm := chain.NewManager(store, genesisState) - expectedPayout := cm.TipState().BlockReward() maturityHeight := cm.TipState().MaturityHeight() @@ -465,28 +443,7 @@ func TestSendTransactions(t *testing.T) { } func TestTip(t *testing.T) { - log := zaptest.NewLogger(t) - dir := t.TempDir() - db, err := sqlite.OpenDatabase(filepath.Join(dir, "explored.sqlite3"), log.Named("sqlite3")) - if err != nil { - t.Fatal(err) - } - defer db.Close() - - bdb, err := coreutils.OpenBoltChainDB(filepath.Join(dir, "consensus.db")) - if err != nil { - t.Fatal(err) - } - defer bdb.Close() - - network, genesisBlock := ctestutil.Network() - - store, genesisState, err := chain.NewDBStore(bdb, network, genesisBlock) - if err != nil { - t.Fatal(err) - } - - cm := chain.NewManager(store, genesisState) + _, _, cm, db := newStore(t, false, nil) const n = 100 for i := cm.Tip().Height; i < n; i++ { @@ -514,21 +471,6 @@ func TestTip(t *testing.T) { } func TestFileContract(t *testing.T) { - log := zaptest.NewLogger(t) - dir := t.TempDir() - - db, err := sqlite.OpenDatabase(filepath.Join(dir, "explored.sqlite3"), log.Named("sqlite3")) - if err != nil { - t.Fatal(err) - } - defer db.Close() - - bdb, err := coreutils.OpenBoltChainDB(filepath.Join(dir, "consensus.db")) - if err != nil { - t.Fatal(err) - } - defer bdb.Close() - pk1 := types.GeneratePrivateKey() addr1 := types.StandardUnlockHash(pk1.PublicKey()) @@ -538,17 +480,11 @@ func TestFileContract(t *testing.T) { hostPrivateKey := types.GeneratePrivateKey() hostPublicKey := hostPrivateKey.PublicKey() - network, genesisBlock := ctestutil.Network() - genesisBlock.Transactions[0].SiacoinOutputs[0].Address = addr1 + _, genesisBlock, cm, db := newStore(t, false, func(network *consensus.Network, genesisBlock types.Block) { + genesisBlock.Transactions[0].SiacoinOutputs[0].Address = addr1 + }) giftSC := genesisBlock.Transactions[0].SiacoinOutputs[0].Value - store, genesisState, err := chain.NewDBStore(bdb, network, genesisBlock) - if err != nil { - t.Fatal(err) - } - - cm := chain.NewManager(store, genesisState) - scOutputID := genesisBlock.Transactions[0].SiacoinOutputID(0) unlockConditions := types.StandardUnlockConditions(pk1.PublicKey()) @@ -770,21 +706,6 @@ func TestFileContract(t *testing.T) { } func TestEphemeralFileContract(t *testing.T) { - log := zaptest.NewLogger(t) - dir := t.TempDir() - - db, err := sqlite.OpenDatabase(filepath.Join(dir, "explored.sqlite3"), log.Named("sqlite3")) - if err != nil { - t.Fatal(err) - } - defer db.Close() - - bdb, err := coreutils.OpenBoltChainDB(filepath.Join(dir, "consensus.db")) - if err != nil { - t.Fatal(err) - } - defer bdb.Close() - pk1 := types.GeneratePrivateKey() addr1 := types.StandardUnlockHash(pk1.PublicKey()) @@ -794,17 +715,11 @@ func TestEphemeralFileContract(t *testing.T) { hostPrivateKey := types.GeneratePrivateKey() hostPublicKey := hostPrivateKey.PublicKey() - network, genesisBlock := ctestutil.Network() - genesisBlock.Transactions[0].SiacoinOutputs[0].Address = addr1 + _, genesisBlock, cm, db := newStore(t, false, func(network *consensus.Network, genesisBlock types.Block) { + genesisBlock.Transactions[0].SiacoinOutputs[0].Address = addr1 + }) giftSC := genesisBlock.Transactions[0].SiacoinOutputs[0].Value - store, genesisState, err := chain.NewDBStore(bdb, network, genesisBlock) - if err != nil { - t.Fatal(err) - } - - cm := chain.NewManager(store, genesisState) - scOutputID := genesisBlock.Transactions[0].SiacoinOutputID(0) unlockConditions := types.StandardUnlockConditions(pk1.PublicKey()) @@ -1019,35 +934,15 @@ func TestEphemeralFileContract(t *testing.T) { } func TestRevertTip(t *testing.T) { - log := zaptest.NewLogger(t) - dir := t.TempDir() - db, err := sqlite.OpenDatabase(filepath.Join(dir, "explored.sqlite3"), log.Named("sqlite3")) - if err != nil { - t.Fatal(err) - } - defer db.Close() - - bdb, err := coreutils.OpenBoltChainDB(filepath.Join(dir, "consensus.db")) - if err != nil { - t.Fatal(err) - } - defer bdb.Close() - - network, genesisBlock := ctestutil.Network() - - store, genesisState, err := chain.NewDBStore(bdb, network, genesisBlock) - if err != nil { - t.Fatal(err) - } - - cm := chain.NewManager(store, genesisState) - pk1 := types.GeneratePrivateKey() addr1 := types.StandardUnlockHash(pk1.PublicKey()) pk2 := types.GeneratePrivateKey() addr2 := types.StandardUnlockHash(pk2.PublicKey()) + _, _, cm, db := newStore(t, false, nil) + genesisState := cm.TipState() + const n = 100 for i := cm.Tip().Height; i < n; i++ { if err := cm.AddBlocks([]types.Block{testutil.MineBlock(cm.TipState(), nil, addr1)}); err != nil { @@ -1107,29 +1002,6 @@ func TestRevertTip(t *testing.T) { } func TestRevertBalance(t *testing.T) { - log := zaptest.NewLogger(t) - dir := t.TempDir() - db, err := sqlite.OpenDatabase(filepath.Join(dir, "explored.sqlite3"), log.Named("sqlite3")) - if err != nil { - t.Fatal(err) - } - defer db.Close() - - bdb, err := coreutils.OpenBoltChainDB(filepath.Join(dir, "consensus.db")) - if err != nil { - t.Fatal(err) - } - defer bdb.Close() - - network, genesisBlock := ctestutil.Network() - - store, genesisState, err := chain.NewDBStore(bdb, network, genesisBlock) - if err != nil { - t.Fatal(err) - } - - cm := chain.NewManager(store, genesisState) - // Generate three addresses: addr1, addr2, addr3 pk1 := types.GeneratePrivateKey() addr1 := types.StandardUnlockHash(pk1.PublicKey()) @@ -1140,6 +1012,9 @@ func TestRevertBalance(t *testing.T) { pk3 := types.GeneratePrivateKey() addr3 := types.StandardUnlockHash(pk3.PublicKey()) + _, _, cm, db := newStore(t, false, nil) + genesisState := cm.TipState() + // t.Log("addr1:", addr1) // t.Log("addr2:", addr2) // t.Log("addr3:", addr3) @@ -1626,33 +1501,12 @@ func TestRevertSendTransactions(t *testing.T) { } func TestHostAnnouncement(t *testing.T) { - log := zaptest.NewLogger(t) - dir := t.TempDir() - db, err := sqlite.OpenDatabase(filepath.Join(dir, "explored.sqlite3"), log.Named("sqlite3")) - if err != nil { - t.Fatal(err) - } - defer db.Close() - - bdb, err := coreutils.OpenBoltChainDB(filepath.Join(dir, "consensus.db")) - if err != nil { - t.Fatal(err) - } - defer bdb.Close() - - network, genesisBlock := ctestutil.Network() - - store, genesisState, err := chain.NewDBStore(bdb, network, genesisBlock) - if err != nil { - t.Fatal(err) - } - - cm := chain.NewManager(store, genesisState) - pk1 := types.GeneratePrivateKey() pk2 := types.GeneratePrivateKey() pk3 := types.GeneratePrivateKey() + _, _, cm, db := newStore(t, false, nil) + checkHostAnnouncements := func(expectedArbitraryData [][]byte, got []chain.HostAnnouncement) { t.Helper() @@ -1833,20 +1687,6 @@ func TestHostAnnouncement(t *testing.T) { } func TestMultipleReorg(t *testing.T) { - log := zaptest.NewLogger(t) - dir := t.TempDir() - db, err := sqlite.OpenDatabase(filepath.Join(dir, "explored.sqlite3"), log.Named("sqlite3")) - if err != nil { - t.Fatal(err) - } - defer db.Close() - - bdb, err := coreutils.OpenBoltChainDB(filepath.Join(dir, "consensus.db")) - if err != nil { - t.Fatal(err) - } - defer bdb.Close() - // Generate three addresses: addr1, addr2, addr3 pk1 := types.GeneratePrivateKey() addr1 := types.StandardUnlockHash(pk1.PublicKey()) @@ -1857,23 +1697,13 @@ func TestMultipleReorg(t *testing.T) { pk3 := types.GeneratePrivateKey() addr3 := types.StandardUnlockHash(pk3.PublicKey()) - // t.Log("addr1:", addr1) - // t.Log("addr2:", addr2) - // t.Log("addr3:", addr3) - - network, genesisBlock := ctestutil.Network() - genesisBlock.Transactions[0].SiacoinOutputs[0].Address = addr1 - genesisBlock.Transactions[0].SiafundOutputs[0].Address = addr1 + _, genesisBlock, cm, db := newStore(t, false, func(network *consensus.Network, genesisBlock types.Block) { + genesisBlock.Transactions[0].SiacoinOutputs[0].Address = addr1 + genesisBlock.Transactions[0].SiafundOutputs[0].Address = addr1 + }) giftSC := genesisBlock.Transactions[0].SiacoinOutputs[0].Value giftSF := genesisBlock.Transactions[0].SiafundOutputs[0].Value - store, genesisState, err := chain.NewDBStore(bdb, network, genesisBlock) - if err != nil { - t.Fatal(err) - } - - cm := chain.NewManager(store, genesisState) - uc1 := types.StandardUnlockConditions(pk1.PublicKey()) // transfer gift from addr1 to addr2 // element gets added at height 1 @@ -2169,21 +1999,6 @@ func TestMultipleReorg(t *testing.T) { } func TestMultipleReorgFileContract(t *testing.T) { - log := zaptest.NewLogger(t) - dir := t.TempDir() - - db, err := sqlite.OpenDatabase(filepath.Join(dir, "explored.sqlite3"), log.Named("sqlite3")) - if err != nil { - t.Fatal(err) - } - defer db.Close() - - bdb, err := coreutils.OpenBoltChainDB(filepath.Join(dir, "consensus.db")) - if err != nil { - t.Fatal(err) - } - defer bdb.Close() - pk1 := types.GeneratePrivateKey() addr1 := types.StandardUnlockHash(pk1.PublicKey()) @@ -2193,17 +2008,12 @@ func TestMultipleReorgFileContract(t *testing.T) { hostPrivateKey := types.GeneratePrivateKey() hostPublicKey := hostPrivateKey.PublicKey() - network, genesisBlock := ctestutil.Network() - genesisBlock.Transactions[0].SiacoinOutputs[0].Address = addr1 + _, genesisBlock, cm, db := newStore(t, false, func(network *consensus.Network, genesisBlock types.Block) { + genesisBlock.Transactions[0].SiacoinOutputs[0].Address = addr1 + }) + genesisState := cm.TipState() giftSC := genesisBlock.Transactions[0].SiacoinOutputs[0].Value - store, genesisState, err := chain.NewDBStore(bdb, network, genesisBlock) - if err != nil { - t.Fatal(err) - } - - cm := chain.NewManager(store, genesisState) - scOutputID := genesisBlock.Transactions[0].SiacoinOutputID(0) unlockConditions := types.StandardUnlockConditions(pk1.PublicKey()) @@ -2505,33 +2315,13 @@ func TestMultipleReorgFileContract(t *testing.T) { } func TestMetricCirculatingSupply(t *testing.T) { - log := zaptest.NewLogger(t) - dir := t.TempDir() - - db, err := sqlite.OpenDatabase(filepath.Join(dir, "explored.sqlite3"), log.Named("sqlite3")) - if err != nil { - t.Fatal(err) - } - defer db.Close() - - bdb, err := coreutils.OpenBoltChainDB(filepath.Join(dir, "consensus.db")) - if err != nil { - t.Fatal(err) - } - defer bdb.Close() - pk1 := types.GeneratePrivateKey() addr1 := types.StandardUnlockHash(pk1.PublicKey()) - network, genesisBlock := ctestutil.Network() - genesisBlock.Transactions[0].SiacoinOutputs[0].Address = addr1 - - store, genesisState, err := chain.NewDBStore(bdb, network, genesisBlock) - if err != nil { - t.Fatal(err) - } - - cm := chain.NewManager(store, genesisState) + _, genesisBlock, cm, db := newStore(t, false, func(network *consensus.Network, genesisBlock types.Block) { + genesisBlock.Transactions[0].SiacoinOutputs[0].Address = addr1 + }) + genesisState := cm.TipState() var circulatingSupply types.Currency if subsidy, ok := genesisState.FoundationSubsidy(); ok { diff --git a/persist/sqlite/v2consensus_test.go b/persist/sqlite/v2consensus_test.go index 5f757d97..8e848b71 100644 --- a/persist/sqlite/v2consensus_test.go +++ b/persist/sqlite/v2consensus_test.go @@ -1,17 +1,12 @@ package sqlite_test import ( - "path/filepath" "testing" + "go.sia.tech/core/consensus" "go.sia.tech/core/types" - "go.sia.tech/coreutils" - "go.sia.tech/coreutils/chain" - ctestutil "go.sia.tech/coreutils/testutil" "go.sia.tech/explored/explorer" "go.sia.tech/explored/internal/testutil" - "go.sia.tech/explored/persist/sqlite" - "go.uber.org/zap/zaptest" ) func getSCE(t *testing.T, db explorer.Store, scid types.SiacoinOutputID) types.SiacoinElement { @@ -32,30 +27,10 @@ func getSCE(t *testing.T, db explorer.Store, scid types.SiacoinOutputID) types.S } func TestV2ArbitraryData(t *testing.T) { - log := zaptest.NewLogger(t) - dir := t.TempDir() - db, err := sqlite.OpenDatabase(filepath.Join(dir, "explored.sqlite3"), log.Named("sqlite3")) - if err != nil { - t.Fatal(err) - } - defer db.Close() - - bdb, err := coreutils.OpenBoltChainDB(filepath.Join(dir, "consensus.db")) - if err != nil { - t.Fatal(err) - } - defer bdb.Close() - - network, genesisBlock := ctestutil.V2Network() - network.HardforkV2.AllowHeight = 1 - network.HardforkV2.RequireHeight = 2 - - store, genesisState, err := chain.NewDBStore(bdb, network, genesisBlock) - if err != nil { - t.Fatal(err) - } - cm := chain.NewManager(store, genesisState) - syncDB(t, db, cm) + _, _, cm, db := newStore(t, true, func(network *consensus.Network, genesisBlock types.Block) { + network.HardforkV2.AllowHeight = 1 + network.HardforkV2.RequireHeight = 2 + }) txn1 := types.V2Transaction{ ArbitraryData: []byte("hello"), @@ -126,38 +101,17 @@ func TestV2ArbitraryData(t *testing.T) { } func TestV2MinerFee(t *testing.T) { - log := zaptest.NewLogger(t) - dir := t.TempDir() - db, err := sqlite.OpenDatabase(filepath.Join(dir, "explored.sqlite3"), log.Named("sqlite3")) - if err != nil { - t.Fatal(err) - } - defer db.Close() - - bdb, err := coreutils.OpenBoltChainDB(filepath.Join(dir, "consensus.db")) - if err != nil { - t.Fatal(err) - } - defer bdb.Close() - pk1 := types.GeneratePrivateKey() addr1 := types.StandardUnlockHash(pk1.PublicKey()) addr1Policy := types.SpendPolicy{Type: types.PolicyTypeUnlockConditions(types.StandardUnlockConditions(pk1.PublicKey()))} - network, genesisBlock := ctestutil.V2Network() - network.HardforkV2.AllowHeight = 1 - network.HardforkV2.RequireHeight = 2 - - genesisBlock.Transactions[0].SiacoinOutputs[0].Address = addr1 + _, genesisBlock, cm, db := newStore(t, true, func(network *consensus.Network, genesisBlock types.Block) { + network.HardforkV2.AllowHeight = 1 + network.HardforkV2.RequireHeight = 2 + genesisBlock.Transactions[0].SiacoinOutputs[0].Address = addr1 + }) giftSC := genesisBlock.Transactions[0].SiacoinOutputs[0].Value - store, genesisState, err := chain.NewDBStore(bdb, network, genesisBlock) - if err != nil { - t.Fatal(err) - } - cm := chain.NewManager(store, genesisState) - syncDB(t, db, cm) - txn1 := types.V2Transaction{ ArbitraryData: []byte("hello"), MinerFee: giftSC, @@ -183,20 +137,6 @@ func TestV2MinerFee(t *testing.T) { } func TestV2FoundationAddress(t *testing.T) { - log := zaptest.NewLogger(t) - dir := t.TempDir() - db, err := sqlite.OpenDatabase(filepath.Join(dir, "explored.sqlite3"), log.Named("sqlite3")) - if err != nil { - t.Fatal(err) - } - defer db.Close() - - bdb, err := coreutils.OpenBoltChainDB(filepath.Join(dir, "consensus.db")) - if err != nil { - t.Fatal(err) - } - defer bdb.Close() - pk1 := types.GeneratePrivateKey() addr1 := types.StandardUnlockHash(pk1.PublicKey()) addr1Policy := types.SpendPolicy{Type: types.PolicyTypeUnlockConditions(types.StandardUnlockConditions(pk1.PublicKey()))} @@ -204,21 +144,14 @@ func TestV2FoundationAddress(t *testing.T) { pk2 := types.GeneratePrivateKey() addr2 := types.StandardUnlockHash(pk2.PublicKey()) - network, genesisBlock := ctestutil.V2Network() - network.HardforkFoundation.PrimaryAddress = addr1 - network.HardforkV2.AllowHeight = 1 - network.HardforkV2.RequireHeight = 2 - - genesisBlock.Transactions[0].SiacoinOutputs[0].Address = addr1 + _, genesisBlock, cm, db := newStore(t, true, func(network *consensus.Network, genesisBlock types.Block) { + network.HardforkV2.AllowHeight = 1 + network.HardforkV2.RequireHeight = 2 + network.HardforkFoundation.PrimaryAddress = addr1 + genesisBlock.Transactions[0].SiacoinOutputs[0].Address = addr1 + }) giftSC := genesisBlock.Transactions[0].SiacoinOutputs[0].Value - store, genesisState, err := chain.NewDBStore(bdb, network, genesisBlock) - if err != nil { - t.Fatal(err) - } - cm := chain.NewManager(store, genesisState) - syncDB(t, db, cm) - txn1 := types.V2Transaction{ SiacoinInputs: []types.V2SiacoinInput{{ Parent: getSCE(t, db, genesisBlock.Transactions[0].SiacoinOutputID(0)),