This repository has been archived by the owner on Apr 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into bip39-support
- Loading branch information
Showing
15 changed files
with
539 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package relayer_test | ||
|
||
import ( | ||
"context" | ||
"math/big" | ||
"time" | ||
|
||
blobstreamtypes "github.com/celestiaorg/orchestrator-relayer/types" | ||
|
||
"github.com/celestiaorg/celestia-app/x/qgb/types" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func (s *HistoricalRelayerTestSuite) TestProcessHistoricAttestation() { | ||
t := s.T() | ||
_, err := s.Node.CelestiaNetwork.WaitForHeightWithTimeout(400, 30*time.Second) | ||
require.NoError(t, err) | ||
|
||
ctx := context.Background() | ||
valset, err := s.Orchestrator.AppQuerier.QueryLatestValset(ctx) | ||
require.NoError(t, err) | ||
|
||
// wait for the valset to be pruned to test if the relayer is able to | ||
// relay using a pruned valset. | ||
for { | ||
_, err = s.Orchestrator.AppQuerier.QueryAttestationByNonce(ctx, valset.Nonce) | ||
if err != nil { | ||
break | ||
} | ||
} | ||
|
||
// sign a test data commitment so that the relayer can relay it | ||
att := types.NewDataCommitment(valset.Nonce+1, 10, 100, time.Now()) | ||
commitment, err := s.Orchestrator.TmQuerier.QueryCommitment(ctx, att.BeginBlock, att.EndBlock) | ||
require.NoError(t, err) | ||
dataRootTupleRoot := blobstreamtypes.DataCommitmentTupleRootSignBytes(big.NewInt(int64(att.Nonce)), commitment) | ||
err = s.Orchestrator.ProcessDataCommitmentEvent(ctx, *att, dataRootTupleRoot) | ||
require.NoError(t, err) | ||
|
||
// process the test data commitment that needs the pruned valset to be relayed. | ||
_, err = s.Relayer.ProcessAttestation(ctx, s.Node.EVMChain.Auth, att) | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package relayer_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/celestiaorg/celestia-app/app" | ||
"github.com/celestiaorg/celestia-app/app/encoding" | ||
"github.com/celestiaorg/celestia-app/test/util/testnode" | ||
"github.com/celestiaorg/celestia-app/x/qgb/types" | ||
"github.com/celestiaorg/orchestrator-relayer/rpc" | ||
|
||
"github.com/celestiaorg/orchestrator-relayer/orchestrator" | ||
|
||
"github.com/celestiaorg/orchestrator-relayer/relayer" | ||
blobstreamtesting "github.com/celestiaorg/orchestrator-relayer/testing" | ||
"github.com/stretchr/testify/require" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type HistoricalRelayerTestSuite struct { | ||
suite.Suite | ||
Node *blobstreamtesting.TestNode | ||
Orchestrator *orchestrator.Orchestrator | ||
Relayer *relayer.Relayer | ||
} | ||
|
||
func (s *HistoricalRelayerTestSuite) SetupSuite() { | ||
t := s.T() | ||
if testing.Short() { | ||
t.Skip("skipping relayer tests in short mode.") | ||
} | ||
ctx := context.Background() | ||
s.Node = blobstreamtesting.NewTestNode( | ||
ctx, | ||
t, | ||
blobstreamtesting.CelestiaNetworkParams{ | ||
GenesisOpts: []testnode.GenesisOption{blobstreamtesting.SetDataCommitmentWindowParams( | ||
encoding.MakeConfig(app.ModuleEncodingRegisters...).Codec, | ||
types.Params{DataCommitmentWindow: 101}, | ||
)}, | ||
TimeIotaMs: 3048000, // so that old attestations are deleted as soon as a new one appears | ||
Pruning: "nothing", // make the node an archive one | ||
TimeoutCommit: 20 * time.Millisecond, | ||
}, | ||
) | ||
_, err := s.Node.CelestiaNetwork.WaitForHeight(2) | ||
require.NoError(t, err) | ||
s.Orchestrator = blobstreamtesting.NewOrchestrator(t, s.Node) | ||
s.Relayer = blobstreamtesting.NewRelayer(t, s.Node) | ||
go s.Node.EVMChain.PeriodicCommit(ctx, time.Millisecond) | ||
initVs, err := s.Relayer.AppQuerier.QueryLatestValset(s.Node.Context) | ||
require.NoError(t, err) | ||
_, _, _, err = s.Relayer.EVMClient.DeployBlobstreamContract(s.Node.EVMChain.Auth, s.Node.EVMChain.Backend, *initVs, initVs.Nonce, true) | ||
require.NoError(t, err) | ||
rpc.BlocksIn20DaysPeriod = 50 | ||
} | ||
|
||
func (s *HistoricalRelayerTestSuite) TearDownSuite() { | ||
s.Node.Close() | ||
} | ||
|
||
func TestHistoricRelayer(t *testing.T) { | ||
suite.Run(t, new(HistoricalRelayerTestSuite)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.