Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: uci/copy-templates #570

Merged
merged 10 commits into from
Aug 6, 2024
19 changes: 19 additions & 0 deletions .github/workflows/go-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Go Checks

on:
pull_request:
push:
branches: ["master"]
workflow_dispatch:
merge_group:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
cancel-in-progress: true

jobs:
go-check:
uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]
4 changes: 4 additions & 0 deletions .github/workflows/go-test-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"skipOSes": ["windows"],
"skipRace": true
}
21 changes: 21 additions & 0 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Go Test

on:
pull_request:
push:
branches: ["master"]
workflow_dispatch:
merge_group:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
cancel-in-progress: true

jobs:
go-test:
uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/release-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release Checker

on:
pull_request_target:
paths: ["version.json"]
types: [ opened, synchronize, reopened, labeled, unlabeled ]
workflow_dispatch:

permissions:
contents: write
pull-requests: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
release-check:
uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]
with:
sources: '["version.json"]'
21 changes: 21 additions & 0 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Releaser

on:
push:
paths: ["version.json"]
workflow_dispatch:

permissions:
contents: write

concurrency:
group: ${{ github.workflow }}-${{ github.sha }}
cancel-in-progress: true

jobs:
releaser:
uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]
with:
sources: '["version.json"]'
secrets:
UCI_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }}
18 changes: 18 additions & 0 deletions .github/workflows/tagpush.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Tag Push Checker

on:
push:
tags:
- v*

permissions:
contents: read
issues: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
releaser:
uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]
1 change: 0 additions & 1 deletion backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func newBackoff(ctx context.Context, sizeThreshold int, cleanupInterval time.Dur
info: make(map[peer.ID]*backoffHistory),
}

rand.Seed(time.Now().UnixNano()) // used for jitter
go b.cleanupLoop(ctx)

return b
Expand Down
12 changes: 7 additions & 5 deletions floodsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package pubsub
import (
"bytes"
"context"
crand "crypto/rand"
"crypto/sha256"
"encoding/base64"
"fmt"
"io"
"math/rand"
mrand "math/rand"
"sort"
"sync"
"testing"
Expand All @@ -20,12 +21,13 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/protocol"

//lint:ignore SA1019 "github.com/libp2p/go-msgio/protoio" is deprecated
"github.com/libp2p/go-msgio/protoio"
)

func checkMessageRouting(t *testing.T, topic string, pubs []*PubSub, subs []*Subscription) {
data := make([]byte, 16)
rand.Read(data)
crand.Read(data)

for _, p := range pubs {
err := p.Publish(topic, data)
Expand Down Expand Up @@ -58,7 +60,7 @@ func denseConnect(t *testing.T, hosts []host.Host) {
func connectSome(t *testing.T, hosts []host.Host, d int) {
for i, a := range hosts {
for j := 0; j < d; j++ {
n := rand.Intn(len(hosts))
n := mrand.Intn(len(hosts))
if n == i {
j--
continue
Expand Down Expand Up @@ -157,7 +159,7 @@ func TestBasicFloodsub(t *testing.T) {
for i := 0; i < 100; i++ {
msg := []byte(fmt.Sprintf("%d the flooooooood %d", i, i))

owner := rand.Intn(len(psubs))
owner := mrand.Intn(len(psubs))

psubs[owner].Publish("foobar", msg)

Expand Down Expand Up @@ -1006,7 +1008,7 @@ func TestConfigurableMaxMessageSize(t *testing.T) {

// 2mb payload.
msg := make([]byte, 1<<21)
rand.Read(msg)
crand.Read(msg)
err := psubs[0].Publish(topic, msg)
if err != nil {
t.Fatal(err)
Expand Down
3 changes: 2 additions & 1 deletion gossipsub_spam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package pubsub

import (
"context"
"math/rand"
"crypto/rand"
"strconv"
"sync"
"testing"
Expand All @@ -15,6 +15,7 @@ import (

pb "github.com/libp2p/go-libp2p-pubsub/pb"

//lint:ignore SA1019 "github.com/libp2p/go-msgio/protoio" is deprecated
"github.com/libp2p/go-msgio/protoio"
)

Expand Down
44 changes: 21 additions & 23 deletions gossipsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package pubsub
import (
"bytes"
"context"
crand "crypto/rand"
"fmt"
"io"
"math/rand"
mrand "math/rand"
"sync"
"sync/atomic"
"testing"
Expand All @@ -19,6 +20,7 @@ import (
"github.com/libp2p/go-libp2p/core/peerstore"
"github.com/libp2p/go-libp2p/core/record"

//lint:ignore SA1019 "github.com/libp2p/go-msgio/protoio" is deprecated
"github.com/libp2p/go-msgio/protoio"
)

Expand Down Expand Up @@ -63,7 +65,7 @@ func TestSparseGossipsub(t *testing.T) {
for i := 0; i < 100; i++ {
msg := []byte(fmt.Sprintf("%d it's not a floooooood %d", i, i))

owner := rand.Intn(len(psubs))
owner := mrand.Intn(len(psubs))

psubs[owner].Publish("foobar", msg)

Expand Down Expand Up @@ -104,7 +106,7 @@ func TestDenseGossipsub(t *testing.T) {
for i := 0; i < 100; i++ {
msg := []byte(fmt.Sprintf("%d it's not a floooooood %d", i, i))

owner := rand.Intn(len(psubs))
owner := mrand.Intn(len(psubs))

psubs[owner].Publish("foobar", msg)

Expand Down Expand Up @@ -358,7 +360,7 @@ func TestGossipsubGossip(t *testing.T) {
for i := 0; i < 100; i++ {
msg := []byte(fmt.Sprintf("%d it's not a floooooood %d", i, i))

owner := rand.Intn(len(psubs))
owner := mrand.Intn(len(psubs))

psubs[owner].Publish("foobar", msg)

Expand Down Expand Up @@ -416,7 +418,7 @@ func TestGossipsubGossipPiggyback(t *testing.T) {
for i := 0; i < 100; i++ {
msg := []byte(fmt.Sprintf("%d it's not a floooooood %d", i, i))

owner := rand.Intn(len(psubs))
owner := mrand.Intn(len(psubs))

psubs[owner].Publish("foobar", msg)
psubs[owner].Publish("bazcrux", msg)
Expand Down Expand Up @@ -563,7 +565,7 @@ func TestGossipsubPrune(t *testing.T) {
for i := 0; i < 10; i++ {
msg := []byte(fmt.Sprintf("%d it's not a floooooood %d", i, i))

owner := rand.Intn(len(psubs))
owner := mrand.Intn(len(psubs))

psubs[owner].Publish("foobar", msg)

Expand Down Expand Up @@ -661,7 +663,7 @@ func TestGossipsubPruneBackoffTime(t *testing.T) {
msg := []byte(fmt.Sprintf("%d it's not a floooooood %d", i, i))

// Don't publish from host 0, since everyone should have pruned it.
owner := rand.Intn(len(psubs)-1) + 1
owner := mrand.Intn(len(psubs)-1) + 1

psubs[owner].Publish("foobar", msg)

Expand Down Expand Up @@ -706,7 +708,7 @@ func TestGossipsubGraft(t *testing.T) {
for i := 0; i < 100; i++ {
msg := []byte(fmt.Sprintf("%d it's not a floooooood %d", i, i))

owner := rand.Intn(len(psubs))
owner := mrand.Intn(len(psubs))

psubs[owner].Publish("foobar", msg)

Expand Down Expand Up @@ -755,7 +757,7 @@ func TestGossipsubRemovePeer(t *testing.T) {
for i := 0; i < 10; i++ {
msg := []byte(fmt.Sprintf("%d it's not a floooooood %d", i, i))

owner := 5 + rand.Intn(len(psubs)-5)
owner := 5 + mrand.Intn(len(psubs)-5)

psubs[owner].Publish("foobar", msg)

Expand Down Expand Up @@ -803,7 +805,7 @@ func TestGossipsubGraftPruneRetry(t *testing.T) {
for i, topic := range topics {
msg := []byte(fmt.Sprintf("%d it's not a floooooood %d", i, i))

owner := rand.Intn(len(psubs))
owner := mrand.Intn(len(psubs))

psubs[owner].Publish(topic, msg)

Expand Down Expand Up @@ -849,7 +851,7 @@ func TestGossipsubControlPiggyback(t *testing.T) {
// create a background flood of messages that overloads the queues
done := make(chan struct{})
go func() {
owner := rand.Intn(len(psubs))
owner := mrand.Intn(len(psubs))
for i := 0; i < 10000; i++ {
msg := []byte("background flooooood")
psubs[owner].Publish("flood", msg)
Expand Down Expand Up @@ -887,7 +889,7 @@ func TestGossipsubControlPiggyback(t *testing.T) {
for i, topic := range topics {
msg := []byte(fmt.Sprintf("%d it's not a floooooood %d", i, i))

owner := rand.Intn(len(psubs))
owner := mrand.Intn(len(psubs))

psubs[owner].Publish(topic, msg)

Expand Down Expand Up @@ -930,7 +932,7 @@ func TestMixedGossipsub(t *testing.T) {
for i := 0; i < 100; i++ {
msg := []byte(fmt.Sprintf("%d it's not a floooooood %d", i, i))

owner := rand.Intn(len(psubs))
owner := mrand.Intn(len(psubs))

psubs[owner].Publish("foobar", msg)

Expand Down Expand Up @@ -1923,13 +1925,11 @@ func TestGossipSubLeaveTopic(t *testing.T) {
connect(t, h[0], h[1])

// Join all peers
var subs []*Subscription
for _, ps := range psubs {
sub, err := ps.Subscribe("test")
vyzo marked this conversation as resolved.
Show resolved Hide resolved
_, err := ps.Subscribe("test")
if err != nil {
t.Fatal(err)
}
subs = append(subs, sub)
}

time.Sleep(time.Second)
Expand Down Expand Up @@ -2004,13 +2004,11 @@ func TestGossipSubJoinTopic(t *testing.T) {
router0.backoff["test"] = peerMap

// Join all peers
var subs []*Subscription
for _, ps := range psubs {
sub, err := ps.Subscribe("test")
_, err := ps.Subscribe("test")
if err != nil {
t.Fatal(err)
}
subs = append(subs, sub)
}

time.Sleep(time.Second)
Expand Down Expand Up @@ -2217,7 +2215,7 @@ func TestGossipsubRPCFragmentation(t *testing.T) {
msgSize := 20000
for i := 0; i < nMessages; i++ {
msg := make([]byte, msgSize)
rand.Read(msg)
crand.Read(msg)
ps.Publish("test", msg)
time.Sleep(20 * time.Millisecond)
}
Expand Down Expand Up @@ -2357,7 +2355,7 @@ func TestFragmentRPCFunction(t *testing.T) {
mkMsg := func(size int) *pb.Message {
msg := &pb.Message{}
msg.Data = make([]byte, size-4) // subtract the protobuf overhead, so msg.Size() returns requested size
rand.Read(msg.Data)
crand.Read(msg.Data)
return msg
}

Expand Down Expand Up @@ -2471,7 +2469,7 @@ func TestFragmentRPCFunction(t *testing.T) {
messageIds := make([]string, msgsPerTopic)
for m := 0; m < msgsPerTopic; m++ {
mid := make([]byte, messageIdSize)
rand.Read(mid)
crand.Read(mid)
messageIds[m] = string(mid)
}
rpc.Control.Ihave[i] = &pb.ControlIHave{MessageIDs: messageIds}
Expand All @@ -2492,7 +2490,7 @@ func TestFragmentRPCFunction(t *testing.T) {
// It should not be present in the fragmented messages, but smaller IDs should be
rpc.Reset()
giantIdBytes := make([]byte, limit*2)
rand.Read(giantIdBytes)
crand.Read(giantIdBytes)
rpc.Control = &pb.ControlMessage{
Iwant: []*pb.ControlIWant{
{MessageIDs: []string{"hello", string(giantIdBytes)}},
Expand Down
Loading
Loading