Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
billettc committed Apr 29, 2020
1 parent 8301980 commit aa5c086
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion abidecoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (a *ABI) read(binaryDecoder *Decoder, fieldName string, fieldType string, j
case "float128":
value, err = binaryDecoder.ReadUint128("float128")
case "bool":
value, err = binaryDecoder.ReadByte()
value, err = binaryDecoder.ReadBool()
case "time_point":
timePoint, e := binaryDecoder.ReadTimePoint() //todo double check
if e == nil {
Expand Down
6 changes: 3 additions & 3 deletions abidecoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,8 @@ func TestABI_Read(t *testing.T) {
{"caseName": "min float64", "typeName": "float64", "value": "0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005", "encode": math.SmallestNonzeroFloat64, "expectedError": nil, "isOptional": false, "isArray": false, "fieldName": "testedField"},
{"caseName": "max float64", "typeName": "float64", "value": "179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "encode": math.MaxFloat64, "expectedError": nil, "isOptional": false, "isArray": false, "fieldName": "testedField"},
{"caseName": "float128", "typeName": "float128", "value": `"0x01000000000000000200000000000000"`, "encode": Float128{Lo: 1, Hi: 2}, "isOptional": false, "isArray": false, "fieldName": "testedField"},
{"caseName": "bool true", "typeName": "bool", "value": "1", "encode": true, "expectedError": nil, "isOptional": false, "isArray": false, "fieldName": "testedField"},
{"caseName": "bool false", "typeName": "bool", "value": "0", "encode": false, "expectedError": nil, "isOptional": false, "isArray": false, "fieldName": "testedField"},
{"caseName": "bool true", "typeName": "bool", "value": "true", "encode": true, "expectedError": nil, "isOptional": false, "isArray": false, "fieldName": "testedField"},
{"caseName": "bool false", "typeName": "bool", "value": "false", "encode": false, "expectedError": nil, "isOptional": false, "isArray": false, "fieldName": "testedField"},
{"caseName": "time_point", "typeName": "time_point", "value": `"2018-11-01T15:13:07.001"`, "encode": TimePoint(1541085187001001), "expectedError": nil, "isOptional": false, "isArray": false, "fieldName": "testedField"},
{"caseName": "time_point_sec", "typeName": "time_point_sec", "value": `"2023-04-14T10:55:53"`, "encode": TimePointSec(1681469753), "expectedError": nil, "isOptional": false, "isArray": false, "fieldName": "testedField"},
{"caseName": "block_timestamp_type", "typeName": "block_timestamp_type", "value": `"2018-09-05T12:48:54"`, "encode": bt, "expectedError": nil, "isOptional": false, "isArray": false, "fieldName": "testedField"},
Expand All @@ -720,7 +720,7 @@ func TestABI_Read(t *testing.T) {
{"caseName": "symbol", "typeName": "symbol", "value": `"4,EOS"`, "encode": EOSSymbol, "expectedError": nil, "isOptional": false, "isArray": false, "fieldName": "testedField"},
{"caseName": "symbol_code", "typeName": "symbol_code", "value": `"BNTDAPP"`, "encode": SymbolCode(22606239386324546), "expectedError": nil, "isOptional": false, "isArray": false, "fieldName": "testedField"},
{"caseName": "asset", "typeName": "asset", "value": `"10.0000 EOS"`, "encode": Asset{Amount: 100000, Symbol: EOSSymbol}, "expectedError": nil, "isOptional": false, "isArray": false, "fieldName": "testedField"},
{"caseName": "extended_asset", "typeName": "extended_asset", "value": "{\"asset\":\"0.0010 EOS\",\"Contract\":\"eoscanadacom\"}", "encode": ExtendedAsset{Asset: Asset{Amount: 10, Symbol: EOSSymbol}, Contract: "eoscanadacom"}, "expectedError": nil, "isOptional": false, "isArray": false, "fieldName": "testedField"},
{"caseName": "extended_asset", "typeName": "extended_asset", "value": "{\"quantity\":\"0.0010 EOS\",\"contract\":\"eoscanadacom\"}", "encode": ExtendedAsset{Asset: Asset{Amount: 10, Symbol: EOSSymbol}, Contract: "eoscanadacom"}, "expectedError": nil, "isOptional": false, "isArray": false, "fieldName": "testedField"},
{"caseName": "bad type", "typeName": "bad.type.1", "value": nil, "encode": nil, "expectedError": fmt.Errorf("decoding field [testedField] of type [bad.type.1]: read field of type [bad.type.1]: unknown type"), "isOptional": false, "isArray": false, "fieldName": "testedField"},
{"caseName": "optional present", "typeName": "string", "value": `"value.1"`, "encode": optional, "expectedError": nil, "isOptional": true, "isArray": false, "fieldName": "testedField"},
{"caseName": "optional not present", "typeName": "string", "value": "", "encode": optionalNotPresent, "expectedError": nil, "isOptional": true, "isArray": false, "fieldName": "testedField"},
Expand Down
4 changes: 2 additions & 2 deletions abiencoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ func TestABI_Write(t *testing.T) {
{"caseName": "symbol_code", "typeName": "symbol_code", "expectedValue": "ffffffffffffffff", "json": "{\"testField\":18446744073709551615}", "expectedError": nil},
{"caseName": "asset", "typeName": "asset", "expectedValue": "a08601000000000004454f5300000000", "json": "{\"testField\":\"10.0000 EOS\"}", "expectedError": nil},
{"caseName": "asset err", "typeName": "asset", "expectedValue": "", "json": "{\"testField\":\"AA.0000 EOS\"}", "expectedError": fmt.Errorf("writing field: asset: strconv.ParseInt: parsing \"AA0000\": invalid syntax")},
{"caseName": "extended_asset", "typeName": "extended_asset", "expectedValue": "0a0000000000000004454f5300000000202932c94c833055", "json": "{\"testField\":{\"asset\":\"0.0010 EOS\",\"Contract\":\"eoscanadacom\"}}", "expectedError": nil},
{"caseName": "extended_asset err", "typeName": "extended_asset", "expectedValue": "", "json": "{\"testField\":{\"asset\":\"abc.0010 EOS\",\"Contract\":\"eoscanadacom\"}}", "expectedError": fmt.Errorf("writing field: extended_asset: strconv.ParseInt: parsing \"abc0010\": invalid syntax")},
{"caseName": "extended_asset", "typeName": "extended_asset", "expectedValue": "0a0000000000000004454f5300000000202932c94c833055", "json": "{\"testField\":{\"quantity\":\"0.0010 EOS\",\"contract\":\"eoscanadacom\"}}", "expectedError": nil},
{"caseName": "extended_asset err", "typeName": "extended_asset", "expectedValue": "", "json": "{\"testField\":{\"quantity\":\"abc.0010 EOS\",\"contract\":\"eoscanadacom\"}}", "expectedError": fmt.Errorf("writing field: extended_asset: strconv.ParseInt: parsing \"abc0010\": invalid syntax")},
{"caseName": "bad type", "typeName": "bad.type.1", "expectedValue": nil, "json": "{\"testField\":0}", "expectedError": fmt.Errorf("writing field of type [bad.type.1]: unknown type")},
{"caseName": "optional present", "typeName": "string", "expectedValue": "0776616c75652e31", "json": "{\"testField\":\"value.1\"}", "expectedError": nil},
{"caseName": "struct", "typeName": "struct_name_1", "expectedValue": "0e746869732e69732e612e74657374", "json": "{\"testField\": {\"field_name_1\":\"this.is.a.test\"}}", "expectedError": nil},
Expand Down

0 comments on commit aa5c086

Please sign in to comment.