Commit 5204a7da authored by Tien Nguyen's avatar Tien Nguyen Committed by GitHub

op-service: add unit test cover address.go file (#11049)

parent b219b848
package eth
import (
"testing"
"github.com/ethereum/go-ethereum/common"
)
func TestAddressAsLeftPaddedHash(t *testing.T) {
// Test cases with different addresses
testCases := []struct {
name string
addr common.Address
expect common.Hash
}{
{
name: "empty address",
addr: common.Address{},
expect: common.HexToHash("0x0000000000000000000000000000000000000000"),
},
{
name: "simple address",
addr: common.HexToAddress("0x1234567890AbCdEf1234567890AbCdEf"),
expect: common.HexToHash("0x000000000000000000000000000000001234567890abcdef1234567890abcdef"),
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
output := AddressAsLeftPaddedHash(tc.addr)
if output != tc.expect {
t.Fatalf("Expected output %v for test case %s, got %v", tc.expect, tc.name, output)
}
})
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment