@@ -1162,19 +1162,19 @@ func buildErrorStringABI(msgBytes []byte) []byte {
11621162 return data
11631163}
11641164
1165- func TestErrorStringUnwrapPlainError (t * testing.T ) {
1165+ func TestErrorStringBinaryWrappedPlainError (t * testing.T ) {
11661166 revertData := ethtypes .MustNewHexBytes0xPrefix (
11671167 "0x08c379a0" +
11681168 "0000000000000000000000000000000000000000000000000000000000000020" +
11691169 "000000000000000000000000000000000000000000000000000000000000001a" +
11701170 "4e6f7420656e6f7567682045746865722070726f76696465642e000000000000" )
11711171
1172- result , ok := ABI {}.ErrorString (revertData , ErrorFormatOption {Unwrap : true })
1172+ result , ok := ABI {}.ErrorString (revertData , ErrorFormatOption {SearchForWrappedBinaryErrors : true })
11731173 assert .True (t , ok )
11741174 assert .Equal (t , `Error("Not enough Ether provided.")` , result )
11751175}
11761176
1177- func TestErrorStringUnwrapSingleNested (t * testing.T ) {
1177+ func TestErrorStringBinaryWrappedSingleNested (t * testing.T ) {
11781178 revertData := ethtypes .MustNewHexBytes0xPrefix (
11791179 "0x08c379a00000000000000000000000000000000000000000000000000000000000000020" +
11801180 "000000000000000000000000000000000000000000000000000000000000006b" +
@@ -1185,12 +1185,12 @@ func TestErrorStringUnwrapSingleNested(t *testing.T) {
11851185 "696e6e6572206572726f72206d65737361676500000000000000000000000000" +
11861186 "000000000000000000000000000000000000000000" )
11871187
1188- result , ok := ABI {}.ErrorString (revertData , ErrorFormatOption {Unwrap : true })
1188+ result , ok := ABI {}.ErrorString (revertData , ErrorFormatOption {SearchForWrappedBinaryErrors : true })
11891189 assert .True (t , ok )
11901190 assert .Equal (t , `outer: Error("inner error message")` , result )
11911191}
11921192
1193- func TestErrorStringUnwrapDoubleNested (t * testing.T ) {
1193+ func TestErrorStringBinaryWrappedDoubleNested (t * testing.T ) {
11941194 revertData := ethtypes .MustNewHexBytes0xPrefix (
11951195 "0x08c379a0" +
11961196 "0000000000000000000000000000000000000000000000000000000000000020" +
@@ -1205,12 +1205,12 @@ func TestErrorStringUnwrapDoubleNested(t *testing.T) {
12051205 "000000000000000000000000000000000000000000000000000000000000000d" +
12061206 "64656570657374206572726f720000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" )
12071207
1208- result , ok := ABI {}.ErrorString (revertData , ErrorFormatOption {Unwrap : true })
1208+ result , ok := ABI {}.ErrorString (revertData , ErrorFormatOption {SearchForWrappedBinaryErrors : true })
12091209 assert .True (t , ok )
12101210 assert .Equal (t , `level1: level2: Error("deepest error")` , result )
12111211}
12121212
1213- func TestErrorStringUnwrapNestedCustomError (t * testing.T ) {
1213+ func TestErrorStringBinaryWrappedNestedCustomError (t * testing.T ) {
12141214 customABI := ABI {
12151215 {Type : Error , Name : "MyCustomError" , Inputs : ParameterArray {{Type : "bytes" }}},
12161216 }
@@ -1229,23 +1229,23 @@ func TestErrorStringUnwrapNestedCustomError(t *testing.T) {
12291229
12301230 // Without the custom ABI the inner error can't be decoded — the
12311231 // outer Error(string) is formatted directly (binary content included)
1232- result , ok := ABI {}.ErrorString (revertData , ErrorFormatOption {Unwrap : true })
1232+ result , ok := ABI {}.ErrorString (revertData , ErrorFormatOption {SearchForWrappedBinaryErrors : true })
12331233 assert .True (t , ok )
12341234 assert .True (t , strings .HasPrefix (result , `Error("[404]01d` ))
12351235
12361236 // With the custom ABI the inner error is decoded
1237- result , ok = customABI .ErrorString (revertData , ErrorFormatOption {Unwrap : true })
1237+ result , ok = customABI .ErrorString (revertData , ErrorFormatOption {SearchForWrappedBinaryErrors : true })
12381238 assert .True (t , ok )
12391239 assert .Equal (t , `[404]01d - caught bytes:MyCustomError("0xdeadbeef")` , result )
12401240}
12411241
1242- func TestErrorStringUnwrapUnknownSelector (t * testing.T ) {
1242+ func TestErrorStringBinaryWrappedUnknownSelector (t * testing.T ) {
12431243 // Unknown top-level selector
1244- _ , ok := ABI {}.ErrorString ([]byte {0x11 , 0x22 , 0x33 , 0x44 }, ErrorFormatOption {Unwrap : true })
1244+ _ , ok := ABI {}.ErrorString ([]byte {0x11 , 0x22 , 0x33 , 0x44 }, ErrorFormatOption {SearchForWrappedBinaryErrors : true })
12451245 assert .False (t , ok )
12461246}
12471247
1248- func TestErrorStringUnwrapMalformedInnerABI (t * testing.T ) {
1248+ func TestErrorStringBinaryWrappedMalformedInner (t * testing.T ) {
12491249 defaultErr := & Entry {Type : Error , Name : "Error" , Inputs : ParameterArray {{Name : "reason" , Type : "string" }}}
12501250 sel := defaultErr .FunctionSelectorBytes ()
12511251
@@ -1254,27 +1254,27 @@ func TestErrorStringUnwrapMalformedInnerABI(t *testing.T) {
12541254
12551255 // Malformed inner data can't be decoded, so the outer Error(string)
12561256 // is formatted directly with the raw string content
1257- result , ok := ABI {}.ErrorString (outerABI , ErrorFormatOption {Unwrap : true })
1257+ result , ok := ABI {}.ErrorString (outerABI , ErrorFormatOption {SearchForWrappedBinaryErrors : true })
12581258 assert .True (t , ok )
12591259 assert .True (t , strings .HasPrefix (result , "Error(" ))
12601260}
12611261
1262- func TestErrorStringUnwrapDepthLimit (t * testing.T ) {
1262+ func TestErrorStringBinaryWrappedDepthLimit (t * testing.T ) {
12631263 // Build a chain deeper than maxRevertErrorDepth (10)
12641264 data := []byte ("leaf" )
12651265 for i := 0 ; i < maxRevertErrorDepth + 2 ; i ++ {
12661266 data = buildErrorStringABI (append ([]byte ("L:" ), data ... ))
12671267 }
12681268
1269- result , ok := ABI {}.ErrorString (data , ErrorFormatOption {Unwrap : true })
1269+ result , ok := ABI {}.ErrorString (data , ErrorFormatOption {SearchForWrappedBinaryErrors : true })
12701270 assert .True (t , ok )
12711271
12721272 // The chain should be capped — the leaf should not be fully unwrapped
12731273 // through all levels, so the result won't contain a cleanly decoded "leaf"
12741274 assert .NotEmpty (t , result )
12751275}
12761276
1277- func TestErrorStringUnwrapCustomBeforeDefault (t * testing.T ) {
1277+ func TestErrorStringBinaryWrappedCustomBeforeDefault (t * testing.T ) {
12781278 customABI := ABI {
12791279 {Type : Error , Name : "EarlyErr" , Inputs : ParameterArray {{Type : "uint256" }}},
12801280 }
@@ -1286,24 +1286,22 @@ func TestErrorStringUnwrapCustomBeforeDefault(t *testing.T) {
12861286 s := "head:" + string (customEncoded ) + "middle:" + string (innerErrorABI )
12871287 outerABI := buildErrorStringABI ([]byte (s ))
12881288
1289- result , ok := customABI .ErrorString (outerABI , ErrorFormatOption {Unwrap : true })
1289+ result , ok := customABI .ErrorString (outerABI , ErrorFormatOption {SearchForWrappedBinaryErrors : true })
12901290 assert .True (t , ok )
12911291 assert .Equal (t , `head:EarlyErr("42")` , result )
12921292}
12931293
12941294// TestErrorStringAssemblyBubbleUp demonstrates that the assembly bubble-up
1295- // pattern produces legible output from ErrorString — with or without Unwrap .
1295+ // pattern produces legible output from ErrorString — with or without SearchForWrappedBinaryErrors .
12961296//
1297- // Solidity's catch-and-rethrow via string.concat wraps the inner error bytes
1298- // inside an Error(string), so ErrorString without Unwrap returns unreadable
1299- // binary. The assembly bubble-up pattern:
1297+ // The assembly bubble-up pattern:
13001298//
13011299// (bool success, bytes memory result) = target.call(data);
13021300// if (!success) { assembly { revert(add(32, result), mload(result)) } }
13031301//
13041302// passes the raw error bytes through unchanged (no outer wrapper), so the
1305- // error is decoded directly and is legible either way. Unwrap is not required
1306- // but is harmless.
1303+ // error is decoded directly and is legible either way. SearchForWrappedBinaryErrors
1304+ // is not required but is harmless.
13071305// TestAssemblyBubbleUpRealPayloads uses revert bytes captured from a live
13081306// Solidity deployment on Kaleido (contract AssemblyRevertTest) where each
13091307// bubbleXxx() function catches its inner revert via `catch (bytes memory data)`
@@ -1384,8 +1382,8 @@ func TestAssemblyBubbleUpRealPayloads(t *testing.T) {
13841382 assert .NoError (t , err )
13851383 assert .Equal (t , tt .wantSig , sig )
13861384
1387- // Unwrap option must not change the result for non-nested payloads
1388- result , ok := tt .abi .ErrorString (revertData , ErrorFormatOption {Unwrap : true })
1385+ // SearchForWrappedBinaryErrors must not change the result for non-nested payloads
1386+ result , ok := tt .abi .ErrorString (revertData , ErrorFormatOption {SearchForWrappedBinaryErrors : true })
13891387 assert .True (t , ok )
13901388 assert .Equal (t , tt .wantStr , result )
13911389 })
@@ -1431,21 +1429,21 @@ func TestErrorStringAssemblyBubbleUp(t *testing.T) {
14311429 assert .True (t , ok )
14321430 assert .Equal (t , `InsufficientBalance("100","200")` , result )
14331431
1434- // With Unwrap : same output — no nesting to unwrap , so result is unchanged.
1435- resultUnwrap , ok := customABI .ErrorString (rawErrorBytes , ErrorFormatOption {Unwrap : true })
1432+ // With SearchForWrappedBinaryErrors : same output — no nesting, so result is unchanged.
1433+ resultUnwrap , ok := customABI .ErrorString (rawErrorBytes , ErrorFormatOption {SearchForWrappedBinaryErrors : true })
14361434 assert .True (t , ok )
14371435 assert .Equal (t , result , resultUnwrap )
14381436
1439- // Contrast: string.concat wraps the same error inside Error(string).
1440- // Without Unwrap the string contains raw binary and is not legible.
1437+ // Contrast: wrapping the same error inside Error(string) embeds binary in the string .
1438+ // Without SearchForWrappedBinaryErrors the string contains raw binary and is not legible.
14411439 wrappedBytes := buildErrorStringABI (append ([]byte ("outer: " ), rawErrorBytes ... ))
14421440 resultWrappedNoUnwrap , ok := customABI .ErrorString (wrappedBytes )
14431441 assert .True (t , ok )
14441442 assert .False (t , strings .HasPrefix (resultWrappedNoUnwrap , "InsufficientBalance" ),
1445- "string.concat wrapping without Unwrap is not legible" )
1443+ "binary-wrapped error without SearchForWrappedBinaryErrors is not legible" )
14461444
1447- // With Unwrap the nesting is decoded and the result is legible again .
1448- resultWrappedUnwrap , ok := customABI .ErrorString (wrappedBytes , ErrorFormatOption {Unwrap : true })
1445+ // With SearchForWrappedBinaryErrors the inner error is decoded and the result is legible.
1446+ resultWrappedUnwrap , ok := customABI .ErrorString (wrappedBytes , ErrorFormatOption {SearchForWrappedBinaryErrors : true })
14491447 assert .True (t , ok )
14501448 assert .Equal (t , `outer: InsufficientBalance("100","200")` , resultWrappedUnwrap )
14511449}
0 commit comments