Skip to content

Commit 749ba08

Browse files
committed
Completely disable swap-related RPCs until fully implemented for the VM
1 parent 699634b commit 749ba08

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

pkg/code/server/account/server.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ func (s *server) LinkAdditionalAccounts(ctx context.Context, req *accountpb.Link
102102
return nil, status.Error(codes.Unavailable, "")
103103
}
104104

105+
// Disable linking swap accounts until swaps implemented fully with the VM
106+
if true {
107+
return nil, status.Error(codes.Unavailable, "")
108+
}
109+
105110
owner, err := common.NewAccountFromProto(req.Owner)
106111
if err != nil {
107112
log.WithError(err).Warn("invalid owner account")

pkg/code/server/account/server_test.go

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,8 @@ func TestGetTokenAccountInfos_NoTokenAccounts(t *testing.T) {
614614
}
615615

616616
func TestLinkAdditionalAccounts_HappyPath(t *testing.T) {
617+
t.Skip("rpc disabled")
618+
617619
env, cleanup := setup(t)
618620
defer cleanup()
619621

@@ -656,6 +658,8 @@ func TestLinkAdditionalAccounts_HappyPath(t *testing.T) {
656658
}
657659

658660
func TestLinkAdditionalAccounts_UserAccountsNotOpened(t *testing.T) {
661+
t.Skip("rpc disabled")
662+
659663
env, cleanup := setup(t)
660664
defer cleanup()
661665

@@ -683,6 +687,8 @@ func TestLinkAdditionalAccounts_UserAccountsNotOpened(t *testing.T) {
683687
}
684688

685689
func TestLinkAdditionalAccounts_InvalidSwapAuthority(t *testing.T) {
690+
t.Skip("rpc disabled")
691+
686692
ownerAccount := testutil.NewRandomAccount(t)
687693
swapAuthorityAccount := testutil.NewRandomAccount(t)
688694
expectedSwapUsdcAta, err := swapAuthorityAccount.ToAssociatedTokenAccount(common.UsdcMintAccount)
@@ -763,7 +769,7 @@ func TestUnauthenticatedRPC(t *testing.T) {
763769
defer cleanup()
764770

765771
ownerAccount := testutil.NewRandomAccount(t)
766-
swapAuthorityAccount := testutil.NewRandomAccount(t)
772+
// swapAuthorityAccount := testutil.NewRandomAccount(t)
767773
maliciousAccount := testutil.NewRandomAccount(t)
768774

769775
isCodeAccountReq := &accountpb.IsCodeAccountRequest{
@@ -790,23 +796,25 @@ func TestUnauthenticatedRPC(t *testing.T) {
790796
_, err = env.client.GetTokenAccountInfos(env.ctx, getTokenAccountInfosReq)
791797
testutil.AssertStatusErrorWithCode(t, err, codes.Unauthenticated)
792798

793-
for i := 0; i < 2; i++ {
794-
linkReq := &accountpb.LinkAdditionalAccountsRequest{
795-
Owner: ownerAccount.ToProto(),
796-
SwapAuthority: swapAuthorityAccount.ToProto(),
797-
}
798-
reqBytes, err = proto.Marshal(linkReq)
799-
require.NoError(t, err)
800-
signatures := []*commonpb.Signature{
801-
{Value: ed25519.Sign(ownerAccount.PrivateKey().ToBytes(), reqBytes)},
802-
{Value: ed25519.Sign(swapAuthorityAccount.PrivateKey().ToBytes(), reqBytes)},
803-
}
804-
signatures[i].Value = ed25519.Sign(maliciousAccount.PrivateKey().ToBytes(), reqBytes)
805-
linkReq.Signatures = signatures
799+
/*
800+
for i := 0; i < 2; i++ {
801+
linkReq := &accountpb.LinkAdditionalAccountsRequest{
802+
Owner: ownerAccount.ToProto(),
803+
SwapAuthority: swapAuthorityAccount.ToProto(),
804+
}
805+
reqBytes, err = proto.Marshal(linkReq)
806+
require.NoError(t, err)
807+
signatures := []*commonpb.Signature{
808+
{Value: ed25519.Sign(ownerAccount.PrivateKey().ToBytes(), reqBytes)},
809+
{Value: ed25519.Sign(swapAuthorityAccount.PrivateKey().ToBytes(), reqBytes)},
810+
}
811+
signatures[i].Value = ed25519.Sign(maliciousAccount.PrivateKey().ToBytes(), reqBytes)
812+
linkReq.Signatures = signatures
806813
807-
_, err = env.client.LinkAdditionalAccounts(env.ctx, linkReq)
808-
testutil.AssertStatusErrorWithCode(t, err, codes.Unauthenticated)
809-
}
814+
_, err = env.client.LinkAdditionalAccounts(env.ctx, linkReq)
815+
testutil.AssertStatusErrorWithCode(t, err, codes.Unauthenticated)
816+
}
817+
*/
810818
}
811819

812820
func setupAccountRecords(t *testing.T, env testEnv, ownerAccount, authorityAccount *common.Account, index uint64, accountType commonpb.AccountType) *common.AccountRecords {

pkg/code/server/transaction/swap.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ func (s *transactionServer) Swap(streamer transactionpb.Transaction_SwapServer)
4848
return handleSwapError(streamer, status.Error(codes.Unavailable, ""))
4949
}
5050

51+
// Disable swaps until implemented fully with the VM
52+
if true {
53+
return handleSwapError(streamer, status.Error(codes.Unavailable, ""))
54+
}
55+
5156
req, err := s.boundedSwapRecv(ctx, streamer)
5257
if err != nil {
5358
log.WithError(err).Info("error receiving request from client")

0 commit comments

Comments
 (0)