testing contract micro optimizations on more inputs

This commit is contained in:
pragmaxim
2026-01-21 09:40:02 +01:00
parent 164fe2de3d
commit 331c523bbd

View File

@@ -26,9 +26,14 @@ func Test_addressFromPaddedHex(t *testing.T) {
input: "0x5dc6288b35e0807a3d6feb89b3a2ff4ab773168e",
wantHex: "5dc6288b35e0807a3d6feb89b3a2ff4ab773168e",
},
{
name: "address_no_padding_no_prefix",
input: "5dc6288b35e0807a3d6feb89b3a2ff4ab773168e",
wantHex: "5dc6288b35e0807a3d6feb89b3a2ff4ab773168e",
},
{
name: "uppercase_prefix",
input: "0X0000000000000000000000005dc6288b35e0807a3d6feb89b3a2ff4ab773168e",
input: "0X0000000000000000000000005DC6288B35E0807A3D6FEB89B3A2FF4AB773168E",
wantHex: "5dc6288b35e0807a3d6feb89b3a2ff4ab773168e",
},
{
@@ -36,6 +41,16 @@ func Test_addressFromPaddedHex(t *testing.T) {
input: "0x0000000000000000000000002aacf811ac1a60081ea39f7783c0d26c500871a8",
wantHex: "2aacf811ac1a60081ea39f7783c0d26c500871a8",
},
{
name: "padded_no_prefix",
input: "0000000000000000000000002aacf811ac1a60081ea39f7783c0d26c500871a8",
wantHex: "2aacf811ac1a60081ea39f7783c0d26c500871a8",
},
{
name: "odd_length_over_40",
input: "f5dc6288b35e0807a3d6feb89b3a2ff4ab773168e",
wantHex: "5dc6288b35e0807a3d6feb89b3a2ff4ab773168e",
},
{
name: "all_zero",
input: "0x0000000000000000000000000000000000000000000000000000000000000000",
@@ -46,6 +61,11 @@ func Test_addressFromPaddedHex(t *testing.T) {
input: "1a2b3c",
wantHex: "00000000000000000000000000000000001a2b3c",
},
{
name: "unpadded_with_prefix",
input: "0x1a2b3c",
wantHex: "00000000000000000000000000000000001a2b3c",
},
{
name: "invalid_fast_path",
input: "0x0000000000000000000000002aacf811ac1a60081ea39f7783c0d26c500871zz",
@@ -56,6 +76,11 @@ func Test_addressFromPaddedHex(t *testing.T) {
input: "0xzz",
wantErr: true,
},
{
name: "invalid_prefix_only",
input: "0x",
wantErr: true,
},
}
for _, tt := range tests {