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

Commit

Permalink
Added a JSValue function for validation results
Browse files Browse the repository at this point in the history
  • Loading branch information
jalextowle committed Jan 30, 2020
1 parent 37a248a commit afeda41
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 139 deletions.
15 changes: 14 additions & 1 deletion browser/go/conversion-test/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ func TestBrowserConversions(t *testing.T) {
defer cancel()

buildForTests(t, ctx)

// Register the test cases that should be logged.
registerContractEventTest()
registerOrderEventTest("EmptyContractEvents", 0)
registerOrderEventTest("ExchangeFillContractEvent", 1)
registerSignedOrderTest("NullAssetData")
registerSignedOrderTest("NonNullAssetData")
registerContractEventTest()
registerValidationResultsTest("emptyValidationResults", 0, 0)

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

// FIXME(jalextowle): Generalize for non-empty validation results
func registerValidationResultsTest(description string, _acceptedLength int, _rejectedLength int) {
registerValidationResultsField(description, "accepted | length")
registerValidationResultsField(description, "rejected | length")
}

func registerOrderEventField(description string, field string) {
registerTest(fmt.Sprintf("(orderEventTest | %s | %s)", description, field))
}
Expand All @@ -257,6 +266,10 @@ func registerSignedOrderField(description string, field string) {
registerTest(fmt.Sprintf("(signedOrderTest | %s | %s)", description, field))
}

func registerValidationResultsField(description string, field string) {
registerTest(fmt.Sprintf("(validationResultsTest | %s | %s)", description, field))
}

func registerTest(test string) {
testCases = append(testCases, fmt.Sprintf("\"%s: true\"", test))
}
Expand Down
8 changes: 8 additions & 0 deletions browser/go/conversion-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/0xProject/0x-mesh/common/types"
"github.com/0xProject/0x-mesh/constants"
"github.com/0xProject/0x-mesh/zeroex"
"github.com/0xProject/0x-mesh/zeroex/ordervalidator"
"github.com/0xProject/0x-mesh/zeroex/orderwatch/decoder"
"github.com/ethereum/go-ethereum/common"
)
Expand Down Expand Up @@ -384,6 +385,13 @@ func setGlobals() {
}, nil
})
}),
"validationResultsAsync": js.FuncOf(func(this js.Value, args []js.Value) interface{} {
return types.WrapInPromise(func() (interface{}, error) {
return []interface{}{
ordervalidator.ValidationResults{},
}, nil
})
}),
}
js.Global().Set("conversionTestCases", conversionTestCases)
}
Expand Down
Loading

0 comments on commit afeda41

Please sign in to comment.