* core/signer, clef: improve ui-test flow, fix errors in uint handling for eip-712 * core/signer: add fuzzer testcases + crashfixes * signer: address review concerns, check sign in integer parsing
		
			
				
	
	
		
			52 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2019 The go-ethereum Authors
 | |
| // This file is part of go-ethereum.
 | |
| //
 | |
| // go-ethereum is free software: you can redistribute it and/or modify
 | |
| // it under the terms of the GNU General Public License as published by
 | |
| // the Free Software Foundation, either version 3 of the License, or
 | |
| // (at your option) any later version.
 | |
| //
 | |
| // go-ethereum is distributed in the hope that it will be useful,
 | |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of
 | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 | |
| // GNU General Public License for more details.
 | |
| //
 | |
| // You should have received a copy of the GNU General Public License
 | |
| // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
 | |
| //
 | |
| package core
 | |
| 
 | |
| import (
 | |
| 	"math/big"
 | |
| 	"testing"
 | |
| )
 | |
| 
 | |
| func TestParseInteger(t *testing.T) {
 | |
| 	for i, tt := range []struct {
 | |
| 		t   string
 | |
| 		v   interface{}
 | |
| 		exp *big.Int
 | |
| 	}{
 | |
| 		{"uint32", "-123", nil},
 | |
| 		{"int32", "-123", big.NewInt(-123)},
 | |
| 		{"uint32", "0xff", big.NewInt(0xff)},
 | |
| 		{"int8", "0xffff", nil},
 | |
| 	} {
 | |
| 		res, err := parseInteger(tt.t, tt.v)
 | |
| 		if tt.exp == nil && res == nil {
 | |
| 			continue
 | |
| 		}
 | |
| 		if tt.exp == nil && res != nil {
 | |
| 			t.Errorf("test %d, got %v, expected nil", i, res)
 | |
| 			continue
 | |
| 		}
 | |
| 		if tt.exp != nil && res == nil {
 | |
| 			t.Errorf("test %d, got '%v', expected %v", i, err, tt.exp)
 | |
| 			continue
 | |
| 		}
 | |
| 		if tt.exp.Cmp(res) != 0 {
 | |
| 			t.Errorf("test %d, got %v expected %v", i, res, tt.exp)
 | |
| 		}
 | |
| 	}
 | |
| }
 |