Skip to content

Commit 91c43a0

Browse files
refactor: API protocol (#285)
* refactor: API protocol * fix: resolve issues after rebase
1 parent 7b0db23 commit 91c43a0

44 files changed

Lines changed: 2730 additions & 2618 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

clearnode/app_session_service_test.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestAppSessionService_CreateApplication(t *testing.T) {
3636
require.NoError(t, GetWalletLedger(db, userAddressB).Record(userAccountIDB, "usdc", decimal.NewFromInt(200)))
3737

3838
capturedNotifications := make(map[string][]Notification)
39-
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params ...any) {
39+
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params RPCDataParams) {
4040

4141
capturedNotifications[userID] = append(capturedNotifications[userID], Notification{
4242
userID: userID,
@@ -117,7 +117,7 @@ func TestAppSessionService_CreateApplication(t *testing.T) {
117117
require.NoError(t, db.Create(&SignerWallet{Signer: userAddressA.Hex(), Wallet: userAddressA.Hex()}).Error)
118118
require.NoError(t, GetWalletLedger(db, userAddressA).Record(userAccountIDA, "usdc", decimal.NewFromInt(50))) // Not enough
119119

120-
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params ...any) {}, nil))
120+
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params RPCDataParams) {}, nil))
121121
params := &CreateAppSessionParams{
122122
Definition: AppDefinition{
123123
Protocol: "test-proto",
@@ -148,7 +148,7 @@ func TestAppSessionService_CreateApplication(t *testing.T) {
148148
Status: ChannelStatusChallenged,
149149
}).Error)
150150

151-
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params ...any) {}, nil))
151+
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params RPCDataParams) {}, nil))
152152
params := &CreateAppSessionParams{
153153
Definition: AppDefinition{
154154
Protocol: "test-proto",
@@ -175,7 +175,7 @@ func TestAppSessionService_CreateApplication(t *testing.T) {
175175
require.NoError(t, db.Create(&SignerWallet{Signer: userAddressA.Hex(), Wallet: userAddressA.Hex()}).Error)
176176
require.NoError(t, GetWalletLedger(db, userAddressA).Record(userAccountIDA, "usdc", decimal.NewFromInt(100)))
177177

178-
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params ...any) {}, nil))
178+
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params RPCDataParams) {}, nil))
179179
params := &CreateAppSessionParams{
180180
Definition: AppDefinition{
181181
Protocol: "test-proto",
@@ -208,7 +208,7 @@ func TestAppSessionService_SubmitAppState(t *testing.T) {
208208
db, cleanup := setupTestDB(t)
209209
defer cleanup()
210210

211-
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params ...any) {}, nil))
211+
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params RPCDataParams) {}, nil))
212212
session := &AppSession{
213213
SessionID: "test-session",
214214
Protocol: "test-proto",
@@ -258,7 +258,7 @@ func TestAppSessionService_SubmitAppState(t *testing.T) {
258258
db, cleanup := setupTestDB(t)
259259
defer cleanup()
260260

261-
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params ...any) {}, nil))
261+
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params RPCDataParams) {}, nil))
262262
session := &AppSession{
263263
SessionID: "test-session-negative",
264264
Protocol: "test-proto",
@@ -307,8 +307,7 @@ func TestAppSessionService_CloseApplication(t *testing.T) {
307307
defer cleanup()
308308

309309
capturedNotifications := make(map[string][]Notification)
310-
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params ...any) {
311-
310+
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params RPCDataParams) {
312311
capturedNotifications[userID] = append(capturedNotifications[userID], Notification{
313312
userID: userID,
314313
eventType: EventType(method),
@@ -395,7 +394,7 @@ func TestAppSessionService_CloseApplication(t *testing.T) {
395394
defer cleanup()
396395

397396
capturedNotifications := make(map[string][]Notification)
398-
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params ...any) {
397+
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params RPCDataParams) {
399398

400399
capturedNotifications[userID] = append(capturedNotifications[userID], Notification{
401400
userID: userID,
@@ -457,7 +456,7 @@ func TestAppSessionService_CloseApplication(t *testing.T) {
457456
db, cleanup := setupTestDB(t)
458457
defer cleanup()
459458

460-
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params ...any) {}, nil))
459+
service := NewAppSessionService(db, NewWSNotifier(func(userID string, method string, params RPCDataParams) {}, nil))
461460
session := &AppSession{
462461
SessionID: "test-session-close-negative",
463462
Protocol: "test-proto",

clearnode/custody_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func setupMockCustody(t *testing.T) (*Custody, *gorm.DB, func()) {
8585
custody: contract,
8686
chainID: uint32(chainID.Int64()),
8787
adjudicatorAddress: newTestCommonAddress("0xAdjudicatorAddress"),
88-
wsNotifier: NewWSNotifier(func(userID string, method string, params ...any) {}, logger),
88+
wsNotifier: NewWSNotifier(func(userID string, method string, params RPCDataParams) {}, logger),
8989
logger: logger,
9090
}
9191

@@ -310,7 +310,7 @@ func TestHandleCreatedEvent(t *testing.T) {
310310
}
311311

312312
capturedNotifications := make(map[string][]Notification)
313-
custody.wsNotifier.notify = func(userID string, method string, params ...any) {
313+
custody.wsNotifier.notify = func(userID string, method string, params RPCDataParams) {
314314
if capturedNotifications[userID] == nil {
315315
capturedNotifications[userID] = make([]Notification, 0)
316316
}
@@ -406,7 +406,7 @@ func TestHandleClosedEvent(t *testing.T) {
406406
_, mockEvent := createMockClosedEvent(t, custody.signer, tokenAddress, finalAmount)
407407

408408
capturedNotifications := make(map[string][]Notification)
409-
custody.wsNotifier.notify = func(userID string, method string, params ...any) {
409+
custody.wsNotifier.notify = func(userID string, method string, params RPCDataParams) {
410410

411411
capturedNotifications[userID] = append(capturedNotifications[userID], Notification{
412412
userID: userID,
@@ -594,7 +594,7 @@ func TestHandleClosedEvent(t *testing.T) {
594594
_, mockEvent := createMockClosedEvent(t, custody.signer, tokenAddress, channelAmount.BigInt())
595595

596596
capturedNotifications := make(map[string][]Notification)
597-
custody.wsNotifier.notify = func(userID string, method string, params ...any) {
597+
custody.wsNotifier.notify = func(userID string, method string, params RPCDataParams) {
598598

599599
capturedNotifications[userID] = append(capturedNotifications[userID], Notification{
600600
userID: userID,
@@ -665,7 +665,7 @@ func TestHandleChallengedEvent(t *testing.T) {
665665
_, mockEvent := createMockChallengedEvent(t, custody.signer, tokenAddress, amount.BigInt())
666666

667667
capturedNotifications := make(map[string][]Notification)
668-
custody.wsNotifier.notify = func(userID string, method string, params ...any) {
668+
custody.wsNotifier.notify = func(userID string, method string, params RPCDataParams) {
669669

670670
capturedNotifications[userID] = append(capturedNotifications[userID], Notification{
671671
userID: userID,
@@ -741,7 +741,7 @@ func TestHandleResizedEvent(t *testing.T) {
741741
_, mockEvent := createMockResizedEvent(t, deltaAmount.BigInt())
742742

743743
capturedNotifications := make(map[string][]Notification)
744-
custody.wsNotifier.notify = func(userID string, method string, params ...any) {
744+
custody.wsNotifier.notify = func(userID string, method string, params RPCDataParams) {
745745

746746
capturedNotifications[userID] = append(capturedNotifications[userID], Notification{
747747
userID: userID,
@@ -901,7 +901,7 @@ func TestHandleResizedEvent(t *testing.T) {
901901
_, mockEvent := createMockResizedEvent(t, big.NewInt(500000))
902902

903903
capturedNotifications := make(map[string][]Notification)
904-
custody.wsNotifier.notify = func(userID string, method string, params ...any) {
904+
custody.wsNotifier.notify = func(userID string, method string, params RPCDataParams) {
905905

906906
capturedNotifications[userID] = append(capturedNotifications[userID], Notification{
907907
userID: userID,

0 commit comments

Comments
 (0)