Skip to content

Commit ad99917

Browse files
committed
more testing
1 parent 25abbed commit ad99917

File tree

1 file changed

+85
-124
lines changed

1 file changed

+85
-124
lines changed

sdk-clients/fusionplus/escrowextension_test.go

Lines changed: 85 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -69,130 +69,91 @@ func TestGenerateSalt(t *testing.T) {
6969
}
7070
}
7171

72-
//TODO commenting out until Fusion is working again
73-
//func TestNewExtension(t *testing.T) {
74-
// tests := []struct {
75-
// name string
76-
// params EscrowExtensionParams
77-
// expected *EscrowExtension
78-
// expectErr bool
79-
// errMsg string
80-
// }{
81-
// {
82-
// name: "Valid parameters with Escrow",
83-
// params: EscrowExtensionParams{
84-
// ExtensionParams: fusion.ExtensionParams{
85-
// SettlementContract: "0x5678",
86-
// AuctionDetails: &fusion.AuctionDetails{
87-
// StartTime: 0,
88-
// Duration: 0,
89-
// InitialRateBump: 0,
90-
// Points: nil,
91-
// GasCost: fusion.GasCostConfigClassFixed{},
92-
// },
93-
// PostInteractionData: &fusion.SettlementPostInteractionData{
94-
// Whitelist: []fusion.WhitelistItem{},
95-
// IntegratorFee: &fusion.IntegratorFee{
96-
// Ratio: big.NewInt(0),
97-
// Receiver: common.Address{},
98-
// },
99-
// BankFee: big.NewInt(0),
100-
// ResolvingStartTime: big.NewInt(0),
101-
// CustomReceiver: common.Address{},
102-
// },
103-
// },
104-
// },
105-
// expected: &EscrowExtension{
106-
// Extension: fusion.Extension{
107-
// MakerAssetSuffix: "0x1234",
108-
// TakerAssetSuffix: "0x1234",
109-
// MakingAmountData: "0x0000000000000000000000000000000000005678",
110-
// TakingAmountData: "0x0000000000000000000000000000000000005678",
111-
// Predicate: "0x1234",
112-
// MakerPermit: "0x00000000000000000000000000000000000012343456",
113-
// PreInteraction: "0xpre",
114-
// PostInteraction: "0x0000000000000000000000000000000000005678",
115-
// },
116-
// },
117-
// expectErr: false,
118-
// },
119-
// {
120-
// name: "Invalid MakerAssetSuffix",
121-
// params: EscrowExtensionParams{
122-
// ExtensionParams: fusion.ExtensionParams{
123-
// SettlementContract: "0x5678",
124-
// MakerAssetSuffix: "invalid",
125-
// TakerAssetSuffix: "0x1234",
126-
// Predicate: "0x1234",
127-
// PreInteraction: "pre",
128-
// },
129-
// },
130-
// expectErr: true,
131-
// errMsg: "MakerAssetSuffix must be valid hex string",
132-
// },
133-
// {
134-
// name: "Invalid TakerAssetSuffix",
135-
// params: EscrowExtensionParams{
136-
// ExtensionParams: fusion.ExtensionParams{
137-
// SettlementContract: "0x5678",
138-
// MakerAssetSuffix: "0x1234",
139-
// TakerAssetSuffix: "invalid",
140-
// Predicate: "0x1234",
141-
// PreInteraction: "pre",
142-
// },
143-
// },
144-
// expectErr: true,
145-
// errMsg: "TakerAssetSuffix must be valid hex string",
146-
// },
147-
// {
148-
// name: "Invalid Predicate",
149-
// params: EscrowExtensionParams{
150-
// ExtensionParams: fusion.ExtensionParams{
151-
// SettlementContract: "0x5678",
152-
// MakerAssetSuffix: "0x1234",
153-
// TakerAssetSuffix: "0x1234",
154-
// Predicate: "invalid",
155-
// PreInteraction: "pre",
156-
// },
157-
// },
158-
// expectErr: true,
159-
// errMsg: "Predicate must be valid hex string",
160-
// },
161-
// {
162-
// name: "CustomData not supported",
163-
// params: EscrowExtensionParams{
164-
// ExtensionParams: fusion.ExtensionParams{
165-
// SettlementContract: "0x5678",
166-
// MakerAssetSuffix: "0x1234",
167-
// TakerAssetSuffix: "0x1234",
168-
// Predicate: "0x1234",
169-
// PreInteraction: "pre",
170-
// CustomData: "0x1234",
171-
// },
172-
// },
173-
// expectErr: true,
174-
// errMsg: "CustomData is not currently supported",
175-
// },
176-
// }
177-
//
178-
// for _, tc := range tests {
179-
// t.Run(tc.name, func(t *testing.T) {
180-
// ext, err := NewEscrowExtension(tc.params)
181-
// if tc.expectErr {
182-
// require.Error(t, err)
183-
// assert.Equal(t, tc.errMsg, err.Error())
184-
// } else {
185-
// require.NoError(t, err)
186-
// assert.NotNil(t, ext)
187-
// assert.Equal(t, tc.expected.MakerAssetSuffix, ext.MakerAssetSuffix)
188-
// assert.Equal(t, tc.expected.TakerAssetSuffix, ext.TakerAssetSuffix)
189-
// assert.Equal(t, tc.expected.Predicate, ext.Predicate)
190-
// assert.Equal(t, tc.expected.PreInteraction, ext.PreInteraction)
191-
// assert.Equal(t, tc.expected.PostInteraction, ext.PostInteraction)
192-
// }
193-
// })
194-
// }
195-
//}
72+
func TestNewExtension(t *testing.T) {
73+
tests := []struct {
74+
name string
75+
params EscrowExtensionParams
76+
expected *EscrowExtension
77+
expectErr bool
78+
errMsg string
79+
}{
80+
{
81+
name: "Invalid MakerAssetSuffix",
82+
params: EscrowExtensionParams{
83+
ExtensionParams: fusion.ExtensionParams{
84+
SettlementContract: "0x5678",
85+
MakerAssetSuffix: "invalid",
86+
TakerAssetSuffix: "0x1234",
87+
Predicate: "0x1234",
88+
PreInteraction: "pre",
89+
},
90+
},
91+
expectErr: true,
92+
errMsg: "MakerAssetSuffix must be valid hex string",
93+
},
94+
{
95+
name: "Invalid TakerAssetSuffix",
96+
params: EscrowExtensionParams{
97+
ExtensionParams: fusion.ExtensionParams{
98+
SettlementContract: "0x5678",
99+
MakerAssetSuffix: "0x1234",
100+
TakerAssetSuffix: "invalid",
101+
Predicate: "0x1234",
102+
PreInteraction: "pre",
103+
},
104+
},
105+
expectErr: true,
106+
errMsg: "TakerAssetSuffix must be valid hex string",
107+
},
108+
{
109+
name: "Invalid Predicate",
110+
params: EscrowExtensionParams{
111+
ExtensionParams: fusion.ExtensionParams{
112+
SettlementContract: "0x5678",
113+
MakerAssetSuffix: "0x1234",
114+
TakerAssetSuffix: "0x1234",
115+
Predicate: "invalid",
116+
PreInteraction: "pre",
117+
},
118+
},
119+
expectErr: true,
120+
errMsg: "Predicate must be valid hex string",
121+
},
122+
{
123+
name: "CustomData not supported",
124+
params: EscrowExtensionParams{
125+
ExtensionParams: fusion.ExtensionParams{
126+
SettlementContract: "0x5678",
127+
MakerAssetSuffix: "0x1234",
128+
TakerAssetSuffix: "0x1234",
129+
Predicate: "0x1234",
130+
PreInteraction: "pre",
131+
CustomData: "0x1234",
132+
},
133+
},
134+
expectErr: true,
135+
errMsg: "CustomData is not currently supported",
136+
},
137+
}
138+
139+
for _, tc := range tests {
140+
t.Run(tc.name, func(t *testing.T) {
141+
ext, err := NewEscrowExtension(tc.params)
142+
if tc.expectErr {
143+
require.Error(t, err)
144+
assert.Equal(t, tc.errMsg, err.Error())
145+
} else {
146+
require.NoError(t, err)
147+
assert.NotNil(t, ext)
148+
assert.Equal(t, tc.expected.MakerAssetSuffix, ext.MakerAssetSuffix)
149+
assert.Equal(t, tc.expected.TakerAssetSuffix, ext.TakerAssetSuffix)
150+
assert.Equal(t, tc.expected.Predicate, ext.Predicate)
151+
assert.Equal(t, tc.expected.PreInteraction, ext.PreInteraction)
152+
assert.Equal(t, tc.expected.PostInteraction, ext.PostInteraction)
153+
}
154+
})
155+
}
156+
}
196157

197158
func TestEncodeExtraData(t *testing.T) {
198159
tests := []struct {

0 commit comments

Comments
 (0)