Skip to content

Commit dc6e557

Browse files
add test
1 parent 92363ec commit dc6e557

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

vms/platformvm/block/executor/block_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,57 @@ func TestBlockOptions(t *testing.T) {
332332
manager: manager,
333333
}
334334
},
335+
expectedPreferenceType: &block.BanffCommitBlock{},
336+
expectedErr: nil,
337+
},
338+
{
339+
name: "banff proposal block; can't fetch primary network validator",
340+
blkF: func(ctrl *gomock.Controller) *Block {
341+
var (
342+
stakerTxID = ids.GenerateTestID()
343+
nodeID = ids.GenerateTestNodeID()
344+
subnetID = ids.GenerateTestID()
345+
stakerTx = &txs.Tx{
346+
Unsigned: &txs.AddPermissionlessValidatorTx{
347+
Validator: txs.Validator{
348+
NodeID: nodeID,
349+
},
350+
Subnet: subnetID,
351+
},
352+
}
353+
)
354+
355+
state := state.NewMockState(ctrl)
356+
state.EXPECT().GetTx(stakerTxID).Return(stakerTx, status.Committed, nil)
357+
state.EXPECT().GetCurrentValidator(constants.PrimaryNetworkID, nodeID).Return(nil, database.ErrClosed)
358+
359+
uptimes := uptime.NewMockCalculator(ctrl)
360+
361+
manager := &manager{
362+
backend: &backend{
363+
state: state,
364+
},
365+
txExecutorBackend: &executor.Backend{
366+
Config: &config.Config{
367+
UptimePercentage: 0,
368+
},
369+
Uptimes: uptimes,
370+
},
371+
}
372+
373+
return &Block{
374+
Block: &block.BanffProposalBlock{
375+
ApricotProposalBlock: block.ApricotProposalBlock{
376+
Tx: &txs.Tx{
377+
Unsigned: &txs.RewardValidatorTx{
378+
TxID: stakerTxID,
379+
},
380+
},
381+
},
382+
},
383+
manager: manager,
384+
}
385+
},
335386
expectedPreferenceType: nil,
336387
expectedErr: executor.ErrStakerWithoutPrimaryNetworkValidator,
337388
},

0 commit comments

Comments
 (0)