Skip to content

Commit

Permalink
Merge branch 'main' into uci/copy-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
masih authored Jul 5, 2024
2 parents 6c0467a + 1c7bcad commit 06fb4c9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/publish-ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ jobs:
type=ref,event=branch
type=raw,value=${{ github.ref }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
31 changes: 17 additions & 14 deletions test/f3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (
"github.com/filecoin-project/go-f3/sim/signing"
leveldb "github.com/ipfs/go-ds-leveldb"
logging "github.com/ipfs/go-log/v2"
"github.com/libp2p/go-libp2p"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/peer"
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
"github.com/stretchr/testify/require"
"golang.org/x/xerrors"
)
Expand Down Expand Up @@ -200,6 +200,7 @@ type testEnv struct {
nodes []*testNode
ec *ec.FakeEC
manifestSender *manifest.ManifestSender
net mocknet.Mocknet

manifest manifest.Manifest
}
Expand Down Expand Up @@ -246,7 +247,10 @@ func (e *testEnv) addPowerDeltaForParticipants(ctx context.Context, m *manifest.
if runNodes && newNode {
// connect node
for j := 0; j < nodeLen-1; j++ {
e.connectNodes(ctx, e.nodes[nodeLen-1], e.nodes[j])
_, err := e.net.LinkPeers(e.nodes[nodeLen-1].h.ID(), e.nodes[j].h.ID())
require.NoError(e.t, err)
_, err = e.net.ConnectPeers(e.nodes[nodeLen-1].h.ID(), e.nodes[j].h.ID())
require.NoError(e.t, err)
}
// run
e.runNode(ctx, e.nodes[nodeLen-1])
Expand Down Expand Up @@ -296,7 +300,7 @@ func (e *testEnv) waitForManifestChange(prev manifest.Manifest, timeout time.Dur
}

func newTestEnvironment(t *testing.T, n int, dynamicManifest bool) testEnv {
env := testEnv{t: t}
env := testEnv{t: t, net: mocknet.New()}

// populate manifest
m := base
Expand Down Expand Up @@ -427,32 +431,31 @@ func (e *testEnv) monitorNodesError(ctx context.Context) {
}
}

func (e *testEnv) connectNodes(ctx context.Context, n1, n2 *testNode) {
pi := n2.h.Peerstore().PeerInfo(n2.h.ID())
err := n1.h.Connect(ctx, pi)
require.NoError(e.t, err)
}

func (e *testEnv) Connect(ctx context.Context) {
for i, n := range e.nodes {
for j := i + 1; j < len(e.nodes); j++ {
e.connectNodes(ctx, n, e.nodes[j])
_, err := e.net.LinkPeers(n.h.ID(), e.nodes[j].h.ID())
require.NoError(e.t, err)
_, err = e.net.ConnectPeers(n.h.ID(), e.nodes[j].h.ID())
require.NoError(e.t, err)
}
}

// connect to the manifest server if it exists
if e.manifestSender != nil {
id := e.manifestSender.PeerInfo().ID
for _, n := range e.nodes {
pi := e.manifestSender.PeerInfo()
err := n.h.Connect(ctx, pi)
_, err := e.net.LinkPeers(n.h.ID(), id)
require.NoError(e.t, err)
_, err = e.net.ConnectPeers(n.h.ID(), id)
require.NoError(e.t, err)
}

}
}

func (e *testEnv) newManifestSender(ctx context.Context) {
h, err := libp2p.New(libp2p.ListenAddrStrings("/ip4/0.0.0.0/udp/0/quic-v1"))
h, err := e.net.GenPeer()
require.NoError(e.t, err)

ps, err := pubsub.NewGossipSub(ctx, h)
Expand All @@ -463,7 +466,7 @@ func (e *testEnv) newManifestSender(ctx context.Context) {
}

func (e *testEnv) newF3Instance(ctx context.Context, id int, manifestServer peer.ID) (*testNode, error) {
h, err := libp2p.New(libp2p.ListenAddrStrings("/ip4/0.0.0.0/udp/0/quic-v1"))
h, err := e.net.GenPeer()
if err != nil {
return nil, xerrors.Errorf("creating libp2p host: %w", err)
}
Expand Down

0 comments on commit 06fb4c9

Please sign in to comment.