Skip to content

Commit

Permalink
add test in ten gateway tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zkokelj committed Feb 21, 2024
1 parent 2cb38cb commit e020741
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
14 changes: 13 additions & 1 deletion integration/obscurogateway/gateway_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,24 @@ func NewUser(wallets []wallet.Wallet, serverAddressHTTP string, serverAddressWS
}

func (u GatewayUser) RegisterAccounts() error {
for _, w := range u.Wallets {
err := u.tgClient.RegisterAccount(w.PrivateKey(), w.Address())
if err != nil {
return err
}
testlog.Logger().Info(fmt.Sprintf("Successfully registered address %s for user: %s. With EIP-712 message", w.Address().Hex(), u.tgClient.UserID()))
}

return nil
}

func (u GatewayUser) RegisterAccountsNonEIP712() error {
for _, w := range u.Wallets {
err := u.tgClient.RegisterAccountNonEP712(w.PrivateKey(), w.Address())
if err != nil {
return err
}
testlog.Logger().Info(fmt.Sprintf("Successfully registered address %s for user: %s.", w.Address().Hex(), u.tgClient.UserID()))
testlog.Logger().Info(fmt.Sprintf("Successfully registered address %s for user: %s. With personal sign message", w.Address().Hex(), u.tgClient.UserID()))
}

return nil
Expand Down
15 changes: 15 additions & 0 deletions integration/obscurogateway/tengateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func TestTenGateway(t *testing.T) {
"testUnsubscribe": testUnsubscribe,
"testClosingConnectionWhileSubscribed": testClosingConnectionWhileSubscribed,
"testSubscriptionTopics": testSubscriptionTopics,
"testDifferentMessagesOnRegister": testDifferentMessagesOnRegister,
} {
t.Run(name, func(t *testing.T) {
test(t, httpURL, wsURL, w)
Expand Down Expand Up @@ -604,6 +605,20 @@ func testClosingConnectionWhileSubscribed(t *testing.T, httpURL, wsURL string, w
subscription.Unsubscribe()
}

func testDifferentMessagesOnRegister(t *testing.T, httpURL, wsURL string, w wallet.Wallet) {
user, err := NewUser([]wallet.Wallet{w, datagenerator.RandomWallet(integration.TenChainID)}, httpURL, wsURL)
require.NoError(t, err)
testlog.Logger().Info("Created user with encryption token: %s\n", user.tgClient.UserID())

// register all the accounts for the user with EIP-712 message format
err = user.RegisterAccounts()
require.NoError(t, err)

// register all the accounts for the user with personal sign message format
err = user.RegisterAccountsNonEIP712()
require.NoError(t, err)
}

func transferRandomAddr(t *testing.T, client *ethclient.Client, w wallet.Wallet) common.TxHash { //nolint: unused
ctx := context.Background()
toAddr := datagenerator.RandomAddress()
Expand Down

0 comments on commit e020741

Please sign in to comment.