Skip to content

Commit

Permalink
fix publish tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani committed Nov 8, 2024
1 parent 26cf9ab commit f9edd28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
4 changes: 3 additions & 1 deletion network/network/errors.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package network

import (
"strings"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand All @@ -12,7 +14,7 @@ func isNotFoundErr(err error) bool {
case codes.NotFound:
return true
case codes.Unknown:
if s.Message() == "not found: unknown request" {
if strings.Contains(s.Message(), "not found") {
return true
}
return false
Expand Down
26 changes: 13 additions & 13 deletions network/network/publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestPublish(t *testing.T) {
launchID, projectID, publishError := network.Publish(context.Background(), suite.ChainMock)
require.NoError(t, publishError)
require.Equal(t, testutil.LaunchID, launchID)
require.Equal(t, uint64(0), projectID)
require.Equal(t, int64(-1), projectID)
suite.AssertAllMocks(t)
})

Expand Down Expand Up @@ -157,7 +157,7 @@ func TestPublish(t *testing.T) {
)
require.NoError(t, publishError)
require.Equal(t, testutil.LaunchID, launchID)
require.Equal(t, uint64(0), projectID)
require.Equal(t, int64(-1), projectID)
suite.AssertAllMocks(t)
})

Expand Down Expand Up @@ -220,10 +220,10 @@ func TestPublish(t *testing.T) {
suite.ChainMock.On("ChainID").Return(testutil.ChainID, nil).Once()
suite.ChainMock.On("CacheBinary", testutil.LaunchID).Return(nil).Once()

launchID, projectID, publishError := network.Publish(context.Background(), suite.ChainMock, WithProject(testutil.ProjectID))
launchID, projectID, publishError := network.Publish(context.Background(), suite.ChainMock, WithProject(int64(testutil.ProjectID)))
require.NoError(t, publishError)
require.Equal(t, testutil.LaunchID, launchID)
require.Equal(t, testutil.ProjectID, projectID)
require.Equal(t, testutil.ProjectID, uint64(projectID))
suite.AssertAllMocks(t)
})

Expand Down Expand Up @@ -309,15 +309,15 @@ func TestPublish(t *testing.T) {
suite.ChainMock.On("ChainID").Return(testutil.ChainID, nil).Once()
suite.ChainMock.On("CacheBinary", testutil.LaunchID).Return(nil).Once()

launchID, projectID, publishError := network.Publish(context.Background(), suite.ChainMock, WithProject(testutil.ProjectID),
launchID, projectID, publishError := network.Publish(context.Background(), suite.ChainMock, WithProject(int64(testutil.ProjectID)),
WithPercentageShares([]SharePercent{
SampleSharePercent(t, "foo", 2, 100),
SampleSharePercent(t, "staking", 50, 100),
}),
)
require.NoError(t, publishError)
require.Equal(t, testutil.LaunchID, launchID)
require.Equal(t, testutil.ProjectID, projectID)
require.Equal(t, testutil.ProjectID, uint64(projectID))
suite.AssertAllMocks(t)
})

Expand Down Expand Up @@ -383,7 +383,7 @@ func TestPublish(t *testing.T) {
)
require.NoError(t, publishError)
require.Equal(t, testutil.LaunchID, launchID)
require.Equal(t, uint64(0), projectID)
require.Equal(t, int64(-1), projectID)
suite.AssertAllMocks(t)
})

Expand Down Expand Up @@ -438,7 +438,7 @@ func TestPublish(t *testing.T) {
launchID, projectID, publishError := network.Publish(context.Background(), suite.ChainMock, WithChainID(testutil.ChainID))
require.NoError(t, publishError)
require.Equal(t, testutil.LaunchID, launchID)
require.Equal(t, uint64(0), projectID)
require.Equal(t, int64(-1), projectID)
suite.AssertAllMocks(t)
})

Expand Down Expand Up @@ -500,7 +500,7 @@ func TestPublish(t *testing.T) {
)
require.NoError(t, publishError)
require.Equal(t, testutil.LaunchID, launchID)
require.Equal(t, uint64(0), projectID)
require.Equal(t, int64(-1), projectID)
suite.AssertAllMocks(t)
})

Expand Down Expand Up @@ -555,7 +555,7 @@ func TestPublish(t *testing.T) {
launchID, projectID, publishError := network.Publish(context.Background(), suite.ChainMock, WithChainID(testutil.ChainID))
require.NoError(t, publishError)
require.Equal(t, testutil.LaunchID, launchID)
require.Equal(t, uint64(0), projectID)
require.Equal(t, int64(-1), projectID)
suite.AssertAllMocks(t)
})

Expand Down Expand Up @@ -626,7 +626,7 @@ func TestPublish(t *testing.T) {
launchID, projectID, publishError := network.Publish(context.Background(), suite.ChainMock, Mainnet())
require.NoError(t, publishError)
require.Equal(t, testutil.LaunchID, launchID)
require.Equal(t, testutil.ProjectID, projectID)
require.Equal(t, testutil.ProjectID, uint64(projectID))
suite.AssertAllMocks(t)
})

Expand Down Expand Up @@ -771,7 +771,7 @@ func TestPublish(t *testing.T) {
launchID, projectID, publishError := network.Publish(context.Background(), suite.ChainMock)
require.NoError(t, publishError)
require.Equal(t, testutil.LaunchID, launchID)
require.Equal(t, uint64(0), projectID)
require.Equal(t, int64(-1), projectID)
suite.AssertAllMocks(t)
})

Expand Down Expand Up @@ -849,7 +849,7 @@ func TestPublish(t *testing.T) {
Once()
suite.ChainMock.On("ChainID").Return(testutil.ChainID, nil).Once()

_, _, publishError := network.Publish(context.Background(), suite.ChainMock, WithProject(testutil.ProjectID))
_, _, publishError := network.Publish(context.Background(), suite.ChainMock, WithProject(int64(testutil.ProjectID)))
require.Error(t, publishError)
require.ErrorIs(t, publishError, sdkerrors.ErrNotFound)
suite.AssertAllMocks(t)
Expand Down

0 comments on commit f9edd28

Please sign in to comment.