Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit f439ded

Browse files
committed
Added a JSValue function for validation results
1 parent 8dc2101 commit f439ded

File tree

4 files changed

+215
-139
lines changed

4 files changed

+215
-139
lines changed

browser/go/conversion-test/conversion_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ func TestBrowserConversions(t *testing.T) {
2525
defer cancel()
2626

2727
buildForTests(t, ctx)
28+
29+
// Register the test cases that should be logged.
30+
registerContractEventTest()
2831
registerOrderEventTest("EmptyContractEvents", 0)
2932
registerOrderEventTest("ExchangeFillContractEvent", 1)
3033
registerSignedOrderTest("NullAssetData")
3134
registerSignedOrderTest("NonNullAssetData")
32-
registerContractEventTest()
35+
registerValidationResultsTest("emptyValidationResults", 0, 0)
3336

3437
// Start a simple HTTP server to serve the web page for the browser node.
3538
ts := httptest.NewServer(http.FileServer(http.Dir("../../dist")))
@@ -249,6 +252,12 @@ func registerOrderEventSignedOrder(description string) {
249252
registerOrderEventField(description, boilerplate+"salt")
250253
}
251254

255+
// FIXME(jalextowle): Generalize for non-empty validation results
256+
func registerValidationResultsTest(description string, _acceptedLength int, _rejectedLength int) {
257+
registerValidationResultsField(description, "accepted | length")
258+
registerValidationResultsField(description, "rejected | length")
259+
}
260+
252261
func registerOrderEventField(description string, field string) {
253262
registerTest(fmt.Sprintf("(orderEventTest | %s | %s)", description, field))
254263
}
@@ -257,6 +266,10 @@ func registerSignedOrderField(description string, field string) {
257266
registerTest(fmt.Sprintf("(signedOrderTest | %s | %s)", description, field))
258267
}
259268

269+
func registerValidationResultsField(description string, field string) {
270+
registerTest(fmt.Sprintf("(validationResultsTest | %s | %s)", description, field))
271+
}
272+
260273
func registerTest(test string) {
261274
testCases = append(testCases, fmt.Sprintf("\"%s: true\"", test))
262275
}

browser/go/conversion-test/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/0xProject/0x-mesh/common/types"
1111
"github.com/0xProject/0x-mesh/constants"
1212
"github.com/0xProject/0x-mesh/zeroex"
13+
"github.com/0xProject/0x-mesh/zeroex/ordervalidator"
1314
"github.com/0xProject/0x-mesh/zeroex/orderwatch/decoder"
1415
"github.com/ethereum/go-ethereum/common"
1516
)
@@ -384,6 +385,13 @@ func setGlobals() {
384385
}, nil
385386
})
386387
}),
388+
"validationResultsAsync": js.FuncOf(func(this js.Value, args []js.Value) interface{} {
389+
return types.WrapInPromise(func() (interface{}, error) {
390+
return []interface{}{
391+
ordervalidator.ValidationResults{},
392+
}, nil
393+
})
394+
}),
387395
}
388396
js.Global().Set("conversionTestCases", conversionTestCases)
389397
}

0 commit comments

Comments
 (0)