Skip to content

Commit

Permalink
chore: remove unneeded code
Browse files Browse the repository at this point in the history
  • Loading branch information
EclesioMeloJunior committed Jan 13, 2025
1 parent d42ec86 commit 7d4784d
Showing 1 changed file with 0 additions and 117 deletions.
117 changes: 0 additions & 117 deletions dot/core/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1500,120 +1500,3 @@ func TestService_GetReadProofAt(t *testing.T) {
execTest(t, service, common.Hash{}, [][]byte{{1}}, common.Hash{2}, [][]byte{{2}}, nil)
})
}

func TestEmptyReturn(t *testing.T) {
testcase := map[string]struct {
setupSubsystemAndMessage func(t *testing.T) (*ProspectiveParachains, GetBackableCandidates)
}{
"no_candidates_found": {
setupSubsystemAndMessage: func(t *testing.T) (*ProspectiveParachains, GetBackableCandidates) {
candidateRelayParent := common.Hash{0x01}
paraId := parachaintypes.ParaID(1)
mockRelayParent := relayChainBlockInfo{
Hash: candidateRelayParent,
Number: 10,
}

ancestors := []relayChainBlockInfo{}
baseConstraints := &parachaintypes.Constraints{
MinRelayParentNumber: 5,
}

mockScope, err := newScopeWithAncestors(mockRelayParent, baseConstraints, nil, 10, ancestors)
assert.NoError(t, err)

candidateStorage := newCandidateStorage()

mockView := &View{
activeLeaves: map[common.Hash]bool{
candidateRelayParent: true,
},
perRelayParent: map[common.Hash]*relayParentData{
candidateRelayParent: {
fragmentChains: map[parachaintypes.ParaID]*fragmentChain{
paraId: newFragmentChain(mockScope, candidateStorage),
},
},
},
}

pp := &ProspectiveParachains{
View: mockView,
}

msg := GetBackableCandidates{
RelayParentHash: candidateRelayParent,
ParaId: paraId,
RequestedQty: 3,
Ancestors: mockAncestors,
Response: responseChan,
}

return pp, msg
},
},
"relay_parent_not_active_leaf": {
setupSubsystemAndMessage: func(t *testing.T) (*ProspectiveParachains, GetBackableCandidates) {
candidateRelayParent := common.Hash{0x01}
paraId := parachaintypes.ParaID(1)
mockRelayParent := relayChainBlockInfo{
Hash: candidateRelayParent,
Number: 10,
}

ancestors := []relayChainBlockInfo{}
baseConstraints := &parachaintypes.Constraints{
MinRelayParentNumber: 5,
}

mockScope, err := newScopeWithAncestors(mockRelayParent, baseConstraints, nil, 10, ancestors)
assert.NoError(t, err)

candidateStorage := newCandidateStorage()

mockView := &View{
activeLeaves: map[common.Hash]bool{
candidateRelayParent: true,
},
perRelayParent: map[common.Hash]*relayParentData{
candidateRelayParent: {
fragmentChains: map[parachaintypes.ParaID]*fragmentChain{
paraId: newFragmentChain(mockScope, candidateStorage),
},
},
},
}

pp := &ProspectiveParachains{
View: mockView,
}

msg := GetBackableCandidates{
RelayParentHash: candidateRelayParent,
ParaId: paraId,
RequestedQty: 3,
Ancestors: mockAncestors,
Response: responseChan,
}

return pp, msg
},
},
}

for tname, tt := range testcase {
tt := tt
t.Run(tname, func(t *testing.T) {
pp, msg := tt.setupSubsystemAndMessage()
pp.getBackableCandidates(msg)

select {
case result := <-msg.responseChan:
assert.NotNil(t, result, "Result should not be nil")
assert.Equal(t, 0, len(result), "Expected 0 candidates to be returned")
default:
t.Fatal("No response received from getBackableCandidates")
}
})
}
}

0 comments on commit 7d4784d

Please sign in to comment.