Compare commits

...

4 Commits

Author SHA1 Message Date
bruce-riley 6329ac2aa2
Merge cc0d1c986b into e6dfb9115e 2024-04-25 15:12:23 -05:00
Evan Gray e6dfb9115e node: shorten hostname for load testing 2024-04-25 16:11:57 -04:00
bruce-riley 034c570b33
Node/Acct: Add parameter checks (#3907) 2024-04-25 15:10:01 -05:00
Bruce Riley cc0d1c986b Add admin command tests 2024-04-25 11:47:49 -05:00
5 changed files with 1184 additions and 2 deletions

View File

@ -717,7 +717,7 @@ func runWormchainMigrateContractTemplate(cmd *cobra.Command, args []string) {
log.Fatal("--contract-address must be specified.")
}
if *wormchainMigrateContractInstantiationMsg == "" {
log.Fatal("--instantiate-msg must be specified.")
log.Fatal("--instantiation-msg must be specified.")
}
m := &nodev1.InjectGovernanceVAARequest{

View File

@ -1003,10 +1003,16 @@ func runNode(cmd *cobra.Command, args []string) {
if idx != 0 {
// try to connect to guardian-0
for {
// tilt uses this hostname format
_, err := net.LookupIP("guardian-0.guardian")
if err == nil {
break
}
// load tests use this hostname format
_, err = net.LookupIP("guardian-0")
if err == nil {
break
}
logger.Info("Error resolving guardian-0.guardian. Trying again...")
time.Sleep(time.Second)
}
@ -1151,6 +1157,10 @@ func runNode(cmd *cobra.Command, args []string) {
var accountantWormchainConn, accountantNttWormchainConn *wormconn.ClientConn
if *accountantContract != "" {
if *wormchainURL == "" {
logger.Fatal("if accountantContract is specified, wormchainURL is required", zap.String("component", "gacct"))
}
if *accountantKeyPath == "" {
logger.Fatal("if accountantContract is specified, accountantKeyPath is required", zap.String("component", "gacct"))
}
@ -1183,6 +1193,10 @@ func runNode(cmd *cobra.Command, args []string) {
// If the NTT accountant is enabled, create a wormchain connection for it.
if *accountantNttContract != "" {
if *wormchainURL == "" {
logger.Fatal("if accountantNttContract is specified, wormchainURL is required", zap.String("component", "gacct"))
}
if *accountantNttKeyPath == "" {
logger.Fatal("if accountantNttContract is specified, accountantNttKeyPath is required", zap.String("component", "gacct"))
}

View File

@ -2,6 +2,7 @@
package adminrpc
import (
"bytes"
"context"
"crypto/ecdsa"
"testing"
@ -17,9 +18,11 @@ import (
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/event"
ethRpc "github.com/ethereum/go-ethereum/rpc"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/wormhole-foundation/wormhole/sdk/vaa"
"go.uber.org/zap"
"google.golang.org/protobuf/encoding/prototext"
)
type mockEVMConnector struct {
@ -270,3 +273,47 @@ func TestSignExistingVAA_Valid(t *testing.T) {
v2 := generateMockVAA(1, append(gsKeys, s.gk))
require.Equal(t, v2, res.Vaa)
}
const govGuardianSetIndex = uint32(4)
var govTimestamp = time.Now()
const govEmitterChain = vaa.ChainIDSolana
var govEmitterAddr vaa.Address = [32]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4}
// verifyGovernanceVAA verifies the VAA fields of a generated governance VAA. Note that it doesn't verify the payload because that is
// already verified in `sdk/vaa/payload_test` and we don't want to duplicate all those arrays.
func verifyGovernanceVAA(t *testing.T, v *vaa.VAA, expectedSeqNo uint64, expectedNonce uint32) {
t.Helper()
require.NotNil(t, v)
assert.Equal(t, uint8(vaa.SupportedVAAVersion), v.Version)
assert.Equal(t, govGuardianSetIndex, v.GuardianSetIndex)
assert.Nil(t, v.Signatures)
assert.Equal(t, govTimestamp, v.Timestamp)
assert.Equal(t, expectedNonce, v.Nonce)
assert.Equal(t, expectedSeqNo, v.Sequence)
assert.Equal(t, uint8(32), v.ConsistencyLevel)
assert.Equal(t, govEmitterChain, v.EmitterChain)
assert.True(t, bytes.Equal(govEmitterAddr[:], v.EmitterAddress[:]))
}
// Test_adminCommands executes all of the tests in prototext_test.go, unmarshaling the prototext and feeding it into `GovMsgToVaa`.
func Test_adminCommands(t *testing.T) {
for _, tst := range adminCommandTest {
t.Run(tst.label, func(t *testing.T) {
var msg nodev1.InjectGovernanceVAARequest
err := prototext.Unmarshal([]byte(tst.prototext), &msg)
require.NoError(t, err)
require.Equal(t, 1, len(msg.Messages))
govMsg := msg.Messages[0]
vaa, err := GovMsgToVaa(govMsg, govGuardianSetIndex, govTimestamp)
if tst.errText == "" {
require.NoError(t, err)
verifyGovernanceVAA(t, vaa, govMsg.Sequence, govMsg.Nonce)
} else {
require.ErrorContains(t, err, tst.errText)
}
})
}
}

File diff suppressed because it is too large Load Diff

View File

@ -147,7 +147,7 @@ func GuardianOptionAccountant(
}
if websocket == "" {
return errors.New("if accountantContract is specified, accountantWS is required")
return errors.New("if either accountantContract or accountantNttContract is specified, accountantWS is required")
}
if contract != "" {
if wormchainConn == nil {