From 7ca0916ab902692c9a449c115ce4b2c741b56e80 Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Fri, 7 Jun 2019 23:00:11 +0800 Subject: [PATCH] cmd/registrar, contracts/registrar: fix lints --- cmd/registrar/exec.go | 5 +---- contracts/registrar/registrar_test.go | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cmd/registrar/exec.go b/cmd/registrar/exec.go index 27a846f31e..4859a07e70 100644 --- a/cmd/registrar/exec.go +++ b/cmd/registrar/exec.go @@ -262,10 +262,7 @@ func registerCheckpoint(ctx *cli.Context) error { } sigStrs := strings.Split(ctx.GlobalString(signatureFlag.Name), ",") for _, sig := range sigStrs { - trimmed := strings.TrimSpace(sig) - if strings.HasPrefix(trimmed, "0x") { - trimmed = trimmed[2:] - } + trimmed := strings.TrimPrefix(strings.TrimSpace(sig), "0x") if len(trimmed) != 130 { utils.Fatalf("Invalid signature in --signature: %s", trimmed) } else { diff --git a/contracts/registrar/registrar_test.go b/contracts/registrar/registrar_test.go index a0e030853f..bcfec7856f 100644 --- a/contracts/registrar/registrar_test.go +++ b/contracts/registrar/registrar_test.go @@ -151,7 +151,7 @@ func assertSignature(addr common.Address, index uint64, hash [32]byte, r, s [32] } var signer common.Address copy(signer[:], crypto.Keccak256(pubkey[1:])[12:]) - return bytes.Compare(signer.Bytes(), expect.Bytes()) == 0 + return bytes.Equal(signer.Bytes(), expect.Bytes()) } type Account struct { @@ -213,7 +213,7 @@ func TestCheckpointRegister(t *testing.T) { if lindex != index { return errors.New("latest checkpoint index mismatch") } - if bytes.Compare(lhash[:], hash[:]) != 0 { + if !bytes.Equal(lhash[:], hash[:]) { return errors.New("latest checkpoint hash mismatch") } if lheight.Cmp(height) != 0 {