Skip to content

Commit

Permalink
Merge pull request #918 from iotaledger/api-management-test-fix
Browse files Browse the repository at this point in the history
Fix pruning tests
  • Loading branch information
muXxer authored Apr 18, 2024
2 parents ab8a545 + 4a41e22 commit e45acab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 7 additions & 0 deletions pkg/network/p2p/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,13 @@ func (m *Manager) handleStream(stream p2pnetwork.Stream) {
return
}

if m.ctx == nil {
m.logger.LogDebugf("aborting handling stream, context is nil")
m.closeStream(stream)

return
}

if m.ctx.Err() != nil {
m.logger.LogDebugf("aborting handling stream, context is done")
m.closeStream(stream)
Expand Down
13 changes: 7 additions & 6 deletions tools/docker-network/tests/api_management_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ func Test_ManagementAPI_Peers_BadRequests(t *testing.T) {
func Test_ManagementAPI_Pruning(t *testing.T) {
d := NewDockerTestFramework(t,
WithProtocolParametersOptions(
iotago.WithSupplyOptions(1813620509061365, 63, 1, 4, 0, 0, 0),
iotago.WithTimeProviderOptions(0, time.Now().Unix(), 3, 4),
iotago.WithLivenessOptions(3, 4, 2, 4, 8),
iotago.WithTimeProviderOptions(0, time.Now().Unix(), 4, 4),
iotago.WithLivenessOptions(3, 4, 2, 4, 5),
iotago.WithCongestionControlOptions(1, 1, 1, 400_000, 250_000, 50_000_000, 1000, 100),
iotago.WithRewardsOptions(8, 10, 2, 384),
iotago.WithTargetCommitteeSize(4),
))
),
)
defer d.Stop()

d.AddValidatorNode("V1", "docker-network-inx-validator-1-1", "http://localhost:8050", "rms1pzg8cqhfxqhq7pt37y8cs4v5u4kcc48lquy2k73ehsdhf5ukhya3y5rx2w6")
Expand All @@ -217,7 +217,7 @@ func Test_ManagementAPI_Pruning(t *testing.T) {
currentEpoch := nodeClientV1.CommittedAPI().TimeProvider().EpochFromSlot(info.Status.LatestFinalizedSlot)

// await the start slot of the next epoch
d.AwaitCommitment(nodeClientV1.CommittedAPI().TimeProvider().EpochStart(currentEpoch + 1))
d.AwaitFinalization(nodeClientV1.CommittedAPI().TimeProvider().EpochStart(currentEpoch + 1))
}

type test struct {
Expand Down Expand Up @@ -260,7 +260,8 @@ func Test_ManagementAPI_Pruning(t *testing.T) {

// prune database by size
pruneDatabaseResponse, err := managementClient.PruneDatabaseBySize(getContextWithTimeout(5*time.Second), "5G")
require.ErrorIs(t, err, database.ErrNoPruningNeeded)
// Match the error string since the error chain is lost during the HTTP request.
require.Contains(t, err.Error(), database.ErrNoPruningNeeded.Error())
require.Nil(t, pruneDatabaseResponse)
},
},
Expand Down

0 comments on commit e45acab

Please sign in to comment.