From 698e7f270a420a56f110547ce029ecddffd37ea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caner=20=C3=87=C4=B1dam?= Date: Tue, 6 Jun 2023 17:40:02 +0300 Subject: [PATCH 1/2] use jq instead of sed to get the ipfs cid from the upload output --- scripts/ipfs-add.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ipfs-add.sh b/scripts/ipfs-add.sh index 2ef612e0..79f837f1 100755 --- a/scripts/ipfs-add.sh +++ b/scripts/ipfs-add.sh @@ -1,4 +1,4 @@ #!/bin/bash -curl -s -X POST -F file=@$1 https://ipfs.forta.network/api/v0/add | sed 's/.*Qm/Qm/g' |sed 's/\".*$//g' +curl -s -X POST -F file=@"$1" https://ipfs.forta.network/api/v0/add | jq -r .Hash From 832b3e69710360fe43e50f9980fa013b240fe962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caner=20=C3=87=C4=B1dam?= Date: Tue, 6 Jun 2023 18:00:23 +0300 Subject: [PATCH 2/2] fix the test --- store/scanner_release_test.go | 42 ++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/store/scanner_release_test.go b/store/scanner_release_test.go index 26b8d726..a2534a87 100644 --- a/store/scanner_release_test.go +++ b/store/scanner_release_test.go @@ -2,10 +2,12 @@ package store import ( "context" + "testing" + "github.com/forta-network/forta-core-go/release" "github.com/forta-network/forta-node/config" "github.com/stretchr/testify/assert" - "testing" + "github.com/stretchr/testify/require" ) type mockReleaseStore struct { @@ -22,7 +24,7 @@ func TestNewScannerReleaseStore(t *testing.T) { rs, err := NewScannerReleaseStore(context.Background(), config.Config{ Registry: config.RegistryConfig{ JsonRpc: config.JsonRpcConfig{Url: "https://polygon-rpc.com"}, - ReleaseDistributionUrl: "https://dist.forta.network/manifest/release", + ReleaseDistributionUrl: "https://dist.forta.network/manifests/releases", IPFS: config.IPFSConfig{ GatewayURL: "https://ipfs.forta.network", }, @@ -93,21 +95,25 @@ func TestLookupVersionStore_GetRelease(t *testing.T) { } for _, tst := range tests { - lookup := func() (string, error) { - return tst.mockRef, tst.mockLookupErr - } - lvs := &lookupVersionStore{ - rc: &mockReleaseStore{mockRm: tst.mockRM}, - lookup: lookup, - cachedRelease: tst.mockCached, - } - res, err := lvs.GetRelease(context.Background()) - if tst.expectedErr != nil { - assert.Nil(t, res, tst.name) - assert.Error(t, err, tst.expectedErr, tst.name) - continue - } - assert.NoError(t, err, tst.name) - assert.Equal(t, tst.expectedRef, res.Reference, tst.name) + t.Run(tst.name, func(t *testing.T) { + r := require.New(t) + + lookup := func() (string, error) { + return tst.mockRef, tst.mockLookupErr + } + lvs := &lookupVersionStore{ + rc: &mockReleaseStore{mockRm: tst.mockRM}, + lookup: lookup, + cachedRelease: tst.mockCached, + } + res, err := lvs.GetRelease(context.Background()) + if tst.expectedErr != nil { + r.Nil(res) + r.Error(err, tst.expectedErr) + return + } + r.NoError(err) + r.Equal(tst.expectedRef, res.Reference) + }) } }