github.com/n1ghtfa1l/go-vnt@v0.6.4-alpha.6/core/wavm/tests/sig_test.go (about) 1 package tests 2 3 import ( 4 "encoding/hex" 5 "fmt" 6 "math/big" 7 "testing" 8 9 "github.com/vntchain/go-vnt/common/math" 10 "github.com/vntchain/go-vnt/crypto" 11 ) 12 13 func TestSig(t *testing.T) { 14 res := crypto.Keccak256Hash([]byte("Transfer(address,address,uint256)")) 15 fmt.Printf("res %s\n", res.Hex()) 16 str, _ := hex.DecodeString("a9059cbb0000000000000000000000003dcf0b3787c31b2bdf62d5bc9128a79c2bb1882900000000000000000000000000000000000000000000000000000000000003e8") 17 fmt.Printf("str %+v\n", str) 18 } 19 20 func TestSafeAdd(t *testing.T) { 21 b := new(big.Int) 22 b.SetUint64(2) 23 e := new(big.Int) 24 e.SetUint64(255) 25 26 res := math.Exp(b, e) 27 fmt.Printf("res %d\n", res) 28 subRes := math.U256(new(big.Int).Sub(res, new(big.Int).SetUint64(0))) 29 addRes := math.U256(new(big.Int).Add(subRes, res)) 30 fmt.Printf("addRes %d\n", addRes) 31 }