Skip to content

Commit 282104a

Browse files
chris124567ChrisSchinnerl
authored andcommitted
use variable to remove occurences of ugly n.genesis().Transactions[0].SiacoinOutputID(0) expression
1 parent b179bea commit 282104a

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

persist/sqlite/consensus_refactored_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ func TestSiacoinOutput(t *testing.T) {
170170
n := newTestChain(t, false, func(network *consensus.Network, genesisBlock types.Block) {
171171
genesisBlock.Transactions[0].SiacoinOutputs[0].Address = addr1
172172
})
173+
scID := n.genesis().Transactions[0].SiacoinOutputID(0)
173174

174175
// genesis output should be unspent
175176
// so spentIndex = nil
176-
n.assertSCE(t, n.genesis().Transactions[0].SiacoinOutputID(0), nil, n.genesis().Transactions[0].SiacoinOutputs[0])
177+
n.assertSCE(t, scID, nil, n.genesis().Transactions[0].SiacoinOutputs[0])
177178

178-
scID := n.genesis().Transactions[0].SiacoinOutputID(0)
179179
txn1 := types.Transaction{
180180
SiacoinInputs: []types.SiacoinInput{{
181181
ParentID: scID,
@@ -192,7 +192,7 @@ func TestSiacoinOutput(t *testing.T) {
192192

193193
// genesis output should be spent
194194
tip := n.tipState().Index
195-
n.assertSCE(t, n.genesis().Transactions[0].SiacoinOutputID(0), &tip, n.genesis().Transactions[0].SiacoinOutputs[0])
195+
n.assertSCE(t, scID, &tip, n.genesis().Transactions[0].SiacoinOutputs[0])
196196

197197
// the output from txn1 should exist now that the block with txn1 was
198198
// mined
@@ -202,7 +202,7 @@ func TestSiacoinOutput(t *testing.T) {
202202

203203
// the genesis output should be unspent now because we reverted the block
204204
// containing txn1 which spent it
205-
n.assertSCE(t, n.genesis().Transactions[0].SiacoinOutputID(0), nil, n.genesis().Transactions[0].SiacoinOutputs[0])
205+
n.assertSCE(t, scID, nil, n.genesis().Transactions[0].SiacoinOutputs[0])
206206

207207
// the output from txn1 should not exist after txn1 reverted
208208
{
@@ -226,14 +226,15 @@ func TestEphemeralSiacoinOutput(t *testing.T) {
226226
n := newTestChain(t, false, func(network *consensus.Network, genesisBlock types.Block) {
227227
genesisBlock.Transactions[0].SiacoinOutputs[0].Address = addr1
228228
})
229+
scID := n.genesis().Transactions[0].SiacoinOutputID(0)
229230

230231
// genesis output should be unspent
231232
// so spentIndex = nil
232-
n.assertSCE(t, n.genesis().Transactions[0].SiacoinOutputID(0), nil, n.genesis().Transactions[0].SiacoinOutputs[0])
233+
n.assertSCE(t, scID, nil, n.genesis().Transactions[0].SiacoinOutputs[0])
233234

234235
txn1 := types.Transaction{
235236
SiacoinInputs: []types.SiacoinInput{{
236-
ParentID: n.genesis().Transactions[0].SiacoinOutputID(0),
237+
ParentID: scID,
237238
UnlockConditions: uc1,
238239
}},
239240
SiacoinOutputs: []types.SiacoinOutput{{
@@ -259,7 +260,7 @@ func TestEphemeralSiacoinOutput(t *testing.T) {
259260

260261
tip := n.tipState().Index
261262
// genesis output should be spent
262-
n.assertSCE(t, n.genesis().Transactions[0].SiacoinOutputID(0), &tip, n.genesis().Transactions[0].SiacoinOutputs[0])
263+
n.assertSCE(t, scID, &tip, n.genesis().Transactions[0].SiacoinOutputs[0])
263264

264265
// now that txn1 and txn2 are mined the outputs from them should exist
265266
n.assertSCE(t, txn1.SiacoinOutputID(0), &tip, txn1.SiacoinOutputs[0])
@@ -268,7 +269,7 @@ func TestEphemeralSiacoinOutput(t *testing.T) {
268269
n.revertBlock(t)
269270

270271
// genesis output should be unspent now that we reverted
271-
n.assertSCE(t, n.genesis().Transactions[0].SiacoinOutputID(0), nil, n.genesis().Transactions[0].SiacoinOutputs[0])
272+
n.assertSCE(t, scID, nil, n.genesis().Transactions[0].SiacoinOutputs[0])
272273

273274
// outputs from txn1 and txn2 should not exist because those transactions
274275
// were reverted

0 commit comments

Comments
 (0)