Skip to content

Commit

Permalink
remove dependency on synapse-node for backends/testutil (#126)
Browse files Browse the repository at this point in the history
**Description**

Continuation of #124, removes dependency on synapse-node for simulated backends

 - Replaces dependencies on synapse-node for backend
 - Replaces dependency on testutil
 - Replaces dependency on synapse-common/toml
  • Loading branch information
trajan0x authored Aug 24, 2022
1 parent 904c560 commit 9abcce4
Show file tree
Hide file tree
Showing 120 changed files with 1,339 additions and 366 deletions.
2 changes: 1 addition & 1 deletion agents/agents/notary/notary.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Notary struct {
}

// RefreshInterval is how long to wait before refreshing.
//TODO: This should be done in config.
// TODO: This should be done in config.
var RefreshInterval = 1 * time.Second

// NewNotary creates a new notary.
Expand Down
6 changes: 3 additions & 3 deletions agents/agents/notary/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/synapsecns/sanguine/agents/db"
"github.com/synapsecns/sanguine/agents/domains"
"github.com/synapsecns/sanguine/agents/types"
"github.com/synapsecns/sanguine/core"
"github.com/synapsecns/sanguine/ethergo/signer/signer"
"github.com/synapsecns/synapse-node/contracts/bridge"
"time"
)

Expand Down Expand Up @@ -65,7 +65,7 @@ func (a AttestationProducer) FindLatestNonce(ctx context.Context) (nonce uint32,
}

// update runs the update producer to produce an update.
//nolint: cyclop
// nolint: cyclop
func (a AttestationProducer) update(ctx context.Context) error {
latestNonce, err := a.FindLatestNonce(ctx)
if err != nil {
Expand Down Expand Up @@ -105,7 +105,7 @@ func (a AttestationProducer) update(ctx context.Context) error {
if err != nil {
return fmt.Errorf("could not hash update: %w", err)
}
signature, err := a.signer.SignMessage(ctx, bridge.KappaToSlice(hashedUpdate), false)
signature, err := a.signer.SignMessage(ctx, core.BytesToSlice(hashedUpdate), false)
if err != nil {
return fmt.Errorf("could not sign message: %w", err)
}
Expand Down
10 changes: 5 additions & 5 deletions agents/agents/notary/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ import (
"github.com/synapsecns/sanguine/agents/domains/evm"
"github.com/synapsecns/sanguine/agents/testutil"
"github.com/synapsecns/sanguine/agents/types"
"github.com/synapsecns/sanguine/core/testsuite"
"github.com/synapsecns/sanguine/ethergo/backends"
"github.com/synapsecns/sanguine/ethergo/backends/preset"
"github.com/synapsecns/sanguine/ethergo/signer/signer"
"github.com/synapsecns/sanguine/ethergo/signer/signer/localsigner"
"github.com/synapsecns/sanguine/ethergo/signer/wallet"
"github.com/synapsecns/synapse-node/pkg/chainwatcher"
"github.com/synapsecns/synapse-node/testutils"
"github.com/synapsecns/synapse-node/testutils/backends"
"github.com/synapsecns/synapse-node/testutils/backends/preset"
"math/big"
"testing"
"time"
)

// NotarySuite tests the notary agent.
type NotarySuite struct {
*testutils.TestSuite
*testsuite.TestSuite
testBackend backends.TestBackend
deployManager *testutil.DeployManager
originContract *origin.OriginRef
Expand All @@ -42,7 +42,7 @@ func NewNotarySuite(tb testing.TB) *NotarySuite {
tb.Helper()

return &NotarySuite{
TestSuite: testutils.NewTestSuite(tb),
TestSuite: testsuite.NewTestSuite(tb),
}
}

Expand Down
1 change: 1 addition & 0 deletions agents/config/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (s SignerConfig) IsValid(_ context.Context) (ok bool, err error) {
var ErrUnsupportedSignerType = errors.New("unsupported signer type")

// SignerType is the signer type
//
//go:generate go run golang.org/x/tools/cmd/stringer -type=SignerType -linecomment
type SignerType int

Expand Down
6 changes: 3 additions & 3 deletions agents/config/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ package config_test

import (
"github.com/stretchr/testify/suite"
"github.com/synapsecns/synapse-node/testutils"
"github.com/synapsecns/sanguine/core/testsuite"
"testing"
)

// ConfigSuite is the config test suite.
type ConfigSuite struct {
*testutils.TestSuite
*testsuite.TestSuite
}

// NewConfigSuite creates a end-to-end test suite.
func NewConfigSuite(tb testing.TB) *ConfigSuite {
tb.Helper()
return &ConfigSuite{
TestSuite: testutils.NewTestSuite(tb),
TestSuite: testsuite.NewTestSuite(tb),
}
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package attestationcollector_test
import (
"context"
"fmt"
"github.com/synapsecns/sanguine/core"
"math/big"
"time"

Expand All @@ -13,7 +14,6 @@ import (
"github.com/synapsecns/sanguine/agents/agents/notary"
"github.com/synapsecns/sanguine/agents/contracts/attestationcollector"
"github.com/synapsecns/sanguine/agents/types"
"github.com/synapsecns/synapse-node/contracts/bridge"
)

func (a AttestationCollectorSuite) TestAttestationCollectorSuite() {
Expand Down Expand Up @@ -43,7 +43,7 @@ func (a AttestationCollectorSuite) TestAttestationCollectorSuite() {
hashedAttestation, err := notary.HashAttestation(unsignedAttestation)
Nil(a.T(), err)

signature, err := a.signer.SignMessage(a.GetTestContext(), bridge.KappaToSlice(hashedAttestation), false)
signature, err := a.signer.SignMessage(a.GetTestContext(), core.BytesToSlice(hashedAttestation), false)
Nil(a.T(), err)

signedAttestation := types.NewSignedAttestation(unsignedAttestation, signature)
Expand Down
2 changes: 1 addition & 1 deletion agents/contracts/attestationcollector/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

// AttestationCollectorRef is a bound attestatoin collector contract that returns the address of the attestation collector contract.
//nolint: golint
// nolint: golint
type AttestationCollectorRef struct {
*AttestationCollector
address common.Address
Expand Down
1 change: 1 addition & 0 deletions agents/contracts/attestationcollector/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func (p parserImpl) ParseAttestationSubmitted(log ethTypes.Log) (_ types.Attesta
}

// EventType is the type of the attestation collector events
//
//go:generate go run golang.org/x/tools/cmd/stringer -type=EventType
type EventType uint

Expand Down
15 changes: 8 additions & 7 deletions agents/contracts/attestationcollector/suite_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package attestationcollector_test

import (
"github.com/synapsecns/sanguine/core/testsuite"
"github.com/synapsecns/sanguine/ethergo/contracts"
"math/big"
"testing"

Expand All @@ -12,23 +14,22 @@ import (
"github.com/synapsecns/sanguine/agents/contracts/origin"
"github.com/synapsecns/sanguine/agents/contracts/test/attestationharness"
"github.com/synapsecns/sanguine/agents/testutil"
"github.com/synapsecns/sanguine/ethergo/backends"
"github.com/synapsecns/sanguine/ethergo/backends/preset"
"github.com/synapsecns/sanguine/ethergo/signer/signer"
"github.com/synapsecns/sanguine/ethergo/signer/signer/localsigner"
"github.com/synapsecns/sanguine/ethergo/signer/wallet"
"github.com/synapsecns/synapse-node/testutils"
"github.com/synapsecns/synapse-node/testutils/backends"
"github.com/synapsecns/synapse-node/testutils/backends/preset"
)

// AttestationCollectorSuite is the attestation collector test suite.
type AttestationCollectorSuite struct {
*testutils.TestSuite
*testsuite.TestSuite
originContract *origin.OriginRef
destinationContract *destination.DestinationRef
destinationContractMetadata backends.DeployedContract
destinationContractMetadata contracts.DeployedContract
attestationHarness *attestationharness.AttestationHarnessRef
attestationContract *attestationcollector.AttestationCollectorRef
attestationContractMetadata backends.DeployedContract
attestationContractMetadata contracts.DeployedContract
testBackendOrigin backends.SimulatedTestBackend
testBackendDestination backends.SimulatedTestBackend
wallet wallet.Wallet
Expand All @@ -39,7 +40,7 @@ type AttestationCollectorSuite struct {
func NewAttestationCollectorSuite(tb testing.TB) *AttestationCollectorSuite {
tb.Helper()
return &AttestationCollectorSuite{
TestSuite: testutils.NewTestSuite(tb),
TestSuite: testsuite.NewTestSuite(tb),
}
}

Expand Down
1 change: 1 addition & 0 deletions agents/contracts/destination/destination.metadata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions agents/contracts/destination/destination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package destination_test
import (
"context"
"fmt"
"github.com/synapsecns/sanguine/core"
"math/big"
"time"

Expand All @@ -13,7 +14,6 @@ import (
"github.com/synapsecns/sanguine/agents/agents/notary"
"github.com/synapsecns/sanguine/agents/contracts/destination"
"github.com/synapsecns/sanguine/agents/types"
"github.com/synapsecns/synapse-node/contracts/bridge"
)

func (d DestinationSuite) TestDestinationSuite() {
Expand Down Expand Up @@ -42,7 +42,7 @@ func (d DestinationSuite) TestDestinationSuite() {
hashedAttestation, err := notary.HashAttestation(unsignedAttestation)
Nil(d.T(), err)

signature, err := d.signer.SignMessage(d.GetTestContext(), bridge.KappaToSlice(hashedAttestation), false)
signature, err := d.signer.SignMessage(d.GetTestContext(), core.BytesToSlice(hashedAttestation), false)
Nil(d.T(), err)

signedAttestation := types.NewSignedAttestation(unsignedAttestation, signature)
Expand Down
2 changes: 1 addition & 1 deletion agents/contracts/destination/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

// DestinationRef is a bound destination contract that returns the address of the destination contract.
//nolint: golint
// nolint: golint
type DestinationRef struct {
*Destination
address common.Address
Expand Down
1 change: 1 addition & 0 deletions agents/contracts/destination/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func (p parserImpl) ParseAttestationAccepted(log ethTypes.Log) (_ types.Attestat
}

// EventType is the type of the destination event
//
//go:generate go run golang.org/x/tools/cmd/stringer -type=EventType
type EventType uint

Expand Down
13 changes: 7 additions & 6 deletions agents/contracts/destination/suite_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package destination_test

import (
"github.com/synapsecns/sanguine/core/testsuite"
"github.com/synapsecns/sanguine/ethergo/contracts"
"math/big"
"testing"

Expand All @@ -11,20 +13,19 @@ import (
"github.com/synapsecns/sanguine/agents/contracts/origin"
"github.com/synapsecns/sanguine/agents/contracts/test/attestationharness"
"github.com/synapsecns/sanguine/agents/testutil"
"github.com/synapsecns/sanguine/ethergo/backends"
"github.com/synapsecns/sanguine/ethergo/backends/preset"
"github.com/synapsecns/sanguine/ethergo/signer/signer"
"github.com/synapsecns/sanguine/ethergo/signer/signer/localsigner"
"github.com/synapsecns/sanguine/ethergo/signer/wallet"
"github.com/synapsecns/synapse-node/testutils"
"github.com/synapsecns/synapse-node/testutils/backends"
"github.com/synapsecns/synapse-node/testutils/backends/preset"
)

// DestinationSuite is the destination test suite.
type DestinationSuite struct {
*testutils.TestSuite
*testsuite.TestSuite
originContract *origin.OriginRef
destinationContract *destination.DestinationRef
destinationContractMetadata backends.DeployedContract
destinationContractMetadata contracts.DeployedContract
attestationHarness *attestationharness.AttestationHarnessRef
testBackendOrigin backends.SimulatedTestBackend
testBackendDestination backends.SimulatedTestBackend
Expand All @@ -36,7 +37,7 @@ type DestinationSuite struct {
func NewDestinationSuite(tb testing.TB) *DestinationSuite {
tb.Helper()
return &DestinationSuite{
TestSuite: testutils.NewTestSuite(tb),
TestSuite: testsuite.NewTestSuite(tb),
}
}

Expand Down
2 changes: 1 addition & 1 deletion agents/contracts/notarymanager/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

// NotaryManagerRef is a bound update manager that returns the address of the contract
//nolint: golint
// nolint: golint
type NotaryManagerRef struct {
*NotaryManager
address common.Address
Expand Down
1 change: 1 addition & 0 deletions agents/contracts/notarymanager/notarymanager.metadata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion agents/contracts/origin/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// OriginRef is a bound origin contract that returns the address of the contract.
//nolint: golint
// nolint: golint
type OriginRef struct {
*Origin
address common.Address
Expand Down
1 change: 1 addition & 0 deletions agents/contracts/origin/origin.metadata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions agents/contracts/origin/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func (p parserImpl) ParseDispatch(log ethTypes.Log) (_ types.CommittedMessage, o
}

// EventType is the type of the origin event
//
//go:generate go run golang.org/x/tools/cmd/stringer -type=EventType
type EventType uint

Expand Down
10 changes: 5 additions & 5 deletions agents/contracts/origin/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import (
"github.com/stretchr/testify/suite"
"github.com/synapsecns/sanguine/agents/contracts/origin"
"github.com/synapsecns/sanguine/agents/testutil"
"github.com/synapsecns/synapse-node/testutils"
"github.com/synapsecns/synapse-node/testutils/backends"
"github.com/synapsecns/synapse-node/testutils/backends/simulated"
"github.com/synapsecns/sanguine/core/testsuite"
"github.com/synapsecns/sanguine/ethergo/backends"
"github.com/synapsecns/sanguine/ethergo/backends/simulated"
"testing"
)

// OriginSuite is the origin test suite.
type OriginSuite struct {
*testutils.TestSuite
*testsuite.TestSuite
originContract *origin.OriginRef
testBackend backends.SimulatedTestBackend
}
Expand All @@ -21,7 +21,7 @@ type OriginSuite struct {
func NewOriginSuite(tb testing.TB) *OriginSuite {
tb.Helper()
return &OriginSuite{
TestSuite: testutils.NewTestSuite(tb),
TestSuite: testsuite.NewTestSuite(tb),
}
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion agents/contracts/test/attestationharness/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

// AttestationHarnessRef is an attestation harness reference
//nolint: golint
// nolint: golint
type AttestationHarnessRef struct {
*AttestationHarness
address common.Address
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion agents/contracts/test/destinationharness/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

// DestinationHarnessRef is a destination harness reference
//nolint: golint
// nolint: golint
type DestinationHarnessRef struct {
*DestinationHarness
address common.Address
Expand Down
Loading

0 comments on commit 9abcce4

Please sign in to comment.