Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1d08320
test: integrate synctest in syncutil_test.go
akrem-chabchoub Oct 10, 2025
c562991
test(spinlock): integrate synctest to Wait tests
akrem-chabchoub Oct 10, 2025
644c45f
test(events): integrate synctest to subscriber test
akrem-chabchoub Oct 11, 2025
840f078
test(reserve): integrate synctest for evict test
akrem-chabchoub Oct 11, 2025
54e394b
test(blocker): integrate synctest for blocker tests
akrem-chabchoub Oct 11, 2025
0686fd4
test(pingpong): integrate synctest for ping test
akrem-chabchoub Oct 11, 2025
30043a7
test(agent): integrate synctest for agent tests
akrem-chabchoub Oct 11, 2025
256b775
test(pingpong): remove unnecessary middleware for Windows in ping test
akrem-chabchoub Oct 13, 2025
974f843
test(agent): refine TestAgent for improved goroutine handling
akrem-chabchoub Oct 16, 2025
c06bdfe
test(pullsync): integrate synctest for pullsync tests
akrem-chabchoub Oct 19, 2025
9843847
test(gsoc): integrate synctest for websocket handler tests
akrem-chabchoub Oct 19, 2025
d63f32b
test(soc_mine): integrate synctest for TestSocMine
akrem-chabchoub Oct 19, 2025
6f71e60
test(joiner): integrate synctest for joiner tests
akrem-chabchoub Oct 19, 2025
07d099c
test(ci): fix make file
akrem-chabchoub Oct 20, 2025
8ca3c5f
test(joiner): enhance redundancy tests with dynamic chunk calculations
akrem-chabchoub Oct 20, 2025
8ddfe24
test(ci): temporarily exclude flaky tests in CI runs
akrem-chabchoub Oct 20, 2025
88fae9b
test(ci): update Makefile to prevent test caching and ensure consiste…
akrem-chabchoub Oct 21, 2025
72fa250
test(soc_mine): format soc_mine_test file
akrem-chabchoub Oct 22, 2025
63fb217
test(ci): simplify test command by removing temporary exclusions for …
akrem-chabchoub Oct 22, 2025
3c3b20a
test(gsoc): remove synctest
akrem-chabchoub Oct 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/api/gsoc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func TestGsocWebsocketMultiHandler(t *testing.T) {
// The test opens a websocket, keeps it alive for 500ms, then receives a GSOC message.
func TestGsocPong(t *testing.T) {
t.Parallel()

id := make([]byte, 32)

var (
Expand Down
127 changes: 67 additions & 60 deletions pkg/blocker/blocker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package blocker_test
import (
"os"
"testing"
"testing/synctest"
"time"

"go.uber.org/goleak"
Expand Down Expand Up @@ -38,96 +39,102 @@ func TestMain(m *testing.M) {
func TestBlocksAfterFlagTimeout(t *testing.T) {
t.Parallel()

addr := swarm.RandAddress(t)
blockedC := make(chan swarm.Address, 10)
synctest.Test(t, func(t *testing.T) {
addr := swarm.RandAddress(t)
blockedC := make(chan swarm.Address, 10)

mock := mockBlockLister(func(a swarm.Address, d time.Duration, r string) error {
blockedC <- a
mock := mockBlockLister(func(a swarm.Address, d time.Duration, r string) error {
blockedC <- a

if d != blockTime {
t.Fatalf("block time: want %v, got %v", blockTime, d)
}
if d != blockTime {
t.Fatalf("block time: want %v, got %v", blockTime, d)
}

return nil
})
return nil
})

b := blocker.New(mock, flagTime, blockTime, time.Millisecond, nil, log.Noop)
testutil.CleanupCloser(t, b)
b := blocker.New(mock, flagTime, blockTime, time.Millisecond, nil, log.Noop)
testutil.CleanupCloser(t, b)

// Flagging address shouldn't block it immediately
b.Flag(addr)
if len(blockedC) != 0 {
t.Fatal("blocker did not wait flag duration")
}
// Flagging address shouldn't block it immediately
b.Flag(addr)
if len(blockedC) != 0 {
t.Fatal("blocker did not wait flag duration")
}

time.Sleep(flagTime / 2)
b.Flag(addr) // check that this flag call does not override previous call
if len(blockedC) != 0 {
t.Fatal("blocker did not wait flag duration")
}
time.Sleep(flagTime / 2)
b.Flag(addr) // check that this flag call does not override previous call
if len(blockedC) != 0 {
t.Fatal("blocker did not wait flag duration")
}

// Suspending current goroutine and expect that in this interval
// block listener was called to block flagged address
time.Sleep(flagTime * 3)
// Suspending current goroutine and expect that in this interval
// block listener was called to block flagged address
time.Sleep(flagTime * 3)

if a := <-blockedC; !a.Equal(addr) {
t.Fatalf("expecting flagged address to be blocked")
}
if len(blockedC) != 0 {
t.Fatalf("address should only be blocked once")
}
if a := <-blockedC; !a.Equal(addr) {
t.Fatalf("expecting flagged address to be blocked")
}
if len(blockedC) != 0 {
t.Fatalf("address should only be blocked once")
}
})
}

func TestUnflagBeforeBlock(t *testing.T) {
t.Parallel()

addr := swarm.RandAddress(t)
mock := mockBlockLister(func(a swarm.Address, d time.Duration, r string) error {
t.Fatalf("address should not be blocked")
synctest.Test(t, func(t *testing.T) {
addr := swarm.RandAddress(t)
mock := mockBlockLister(func(a swarm.Address, d time.Duration, r string) error {
t.Fatalf("address should not be blocked")

return nil
})
return nil
})

b := blocker.New(mock, flagTime, blockTime, time.Millisecond, nil, log.Noop)
testutil.CleanupCloser(t, b)
b := blocker.New(mock, flagTime, blockTime, time.Millisecond, nil, log.Noop)
testutil.CleanupCloser(t, b)

// Flagging address shouldn't block it imidietly
b.Flag(addr)
// Flagging address shouldn't block it imidietly
b.Flag(addr)

time.Sleep(flagTime / 2)
b.Flag(addr) // check that this flag call does not override previous call
time.Sleep(flagTime / 2)
b.Flag(addr) // check that this flag call does not override previous call

b.Unflag(addr)
b.Unflag(addr)

// Suspending current goroutine and expect that in this interval
// block listener was not called to block flagged address
time.Sleep(flagTime * 3)
// Suspending current goroutine and expect that in this interval
// block listener was not called to block flagged address
time.Sleep(flagTime * 3)
})
}

func TestPruneBeforeBlock(t *testing.T) {
t.Parallel()

addr := swarm.RandAddress(t)
mock := mockBlockLister(func(a swarm.Address, d time.Duration, r string) error {
t.Fatalf("address should not be blocked")
synctest.Test(t, func(t *testing.T) {
addr := swarm.RandAddress(t)
mock := mockBlockLister(func(a swarm.Address, d time.Duration, r string) error {
t.Fatalf("address should not be blocked")

return nil
})
return nil
})

b := blocker.New(mock, flagTime, blockTime, time.Millisecond, nil, log.Noop)
testutil.CleanupCloser(t, b)
b := blocker.New(mock, flagTime, blockTime, time.Millisecond, nil, log.Noop)
testutil.CleanupCloser(t, b)

// Flagging address shouldn't block it imidietly
b.Flag(addr)
// Flagging address shouldn't block it imidietly
b.Flag(addr)

time.Sleep(flagTime / 2)
time.Sleep(flagTime / 2)

// communicate that we have seen no peers, resulting in the peer being removed
b.PruneUnseen([]swarm.Address{})
// communicate that we have seen no peers, resulting in the peer being removed
b.PruneUnseen([]swarm.Address{})

// Suspending current goroutine expect that in this interval
// block listener was not called to block flagged address
time.Sleep(flagTime * 3)
// Suspending current goroutine expect that in this interval
// block listener was not called to block flagged address
time.Sleep(flagTime * 3)
})
}

type blocklister struct {
Expand Down
Loading
Loading