Skip to content

Commit e6092bd

Browse files
committed
testutil: remove MineBlock in favour of impl in coreutils package
1 parent 5908a8c commit e6092bd

File tree

2 files changed

+3
-26
lines changed

2 files changed

+3
-26
lines changed

testutil/network.go

-25
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package testutil
22

33
import (
4-
"time"
5-
64
"go.sia.tech/core/consensus"
75
"go.sia.tech/core/types"
8-
"go.sia.tech/coreutils"
96
"go.sia.tech/coreutils/chain"
107
)
118

@@ -24,25 +21,3 @@ func Network() (*consensus.Network, types.Block) {
2421
n.HardforkV2.RequireHeight = 250
2522
return n, genesisBlock
2623
}
27-
28-
// MineBlock mines a block with the given transactions, transaction fees are
29-
// added to the miner payout.
30-
func MineBlock(cm *chain.Manager, minerAddress types.Address) types.Block {
31-
state := cm.TipState()
32-
b := types.Block{
33-
ParentID: state.Index.ID,
34-
Timestamp: types.CurrentTimestamp(),
35-
Transactions: cm.PoolTransactions(),
36-
MinerPayouts: []types.SiacoinOutput{{Address: minerAddress, Value: state.BlockReward()}},
37-
}
38-
39-
// add txn fees to miner payout
40-
for _, txn := range b.Transactions {
41-
b.MinerPayouts[0].Value = b.MinerPayouts[0].Value.Add(txn.TotalFees())
42-
}
43-
44-
if !coreutils.FindBlockNonce(state, &b, 5*time.Second) {
45-
panic("failed to find nonce")
46-
}
47-
return b
48-
}

wallet/wallet_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ func syncDB(cm *chain.Manager, store wallet.SingleAddressStore) error {
3737
func mineAndSync(cm *chain.Manager, ws wallet.SingleAddressStore, address types.Address, n uint64) error {
3838
// mine n blocks
3939
for i := uint64(0); i < n; i++ {
40-
if err := cm.AddBlocks([]types.Block{testutil.MineBlock(cm, address)}); err != nil {
40+
if block, found := coreutils.MineBlock(cm, address, 5*time.Second); !found {
41+
panic("failed to mine block")
42+
} else if err := cm.AddBlocks([]types.Block{block}); err != nil {
4143
return fmt.Errorf("failed to add blocks: %w", err)
4244
}
4345
}

0 commit comments

Comments
 (0)