github.com/annchain/OG@v0.0.9/account/account_test.go (about)

     1  package account
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  //func TestSignature(t *testing.T) {
     9  //	acc := NewAccount(fmt.Sprintf("0x0170E6B713CD32904D07A55B3AF5784E0B23EB38589EBF975F0AB89E6F8D786F%02d", 00))
    10  //
    11  //	tx := &types.Txi{
    12  //		From:  acc.Address,
    13  //		To:    common.HexToAddress("0x1234567812345678"),
    14  //		Value: math.NewBigInt(0xAABBCCDDEEFF),
    15  //		TxBase: types.TxBase{
    16  //			PublicKey: acc.PublicKey.KeyBytes,
    17  //			Height:    10,
    18  //		},
    19  //	}
    20  //	signer := &ogcrypto.SignerSecp256k1{}
    21  //
    22  //	beforeSign := tx.SignatureTargets()
    23  //	fmt.Println(hexutil.Encode(beforeSign))
    24  //	sig := signer.Sign(acc.PrivateKey, tx.SignatureTargets())
    25  //	fmt.Println(hexutil.Encode(sig.KeyBytes))
    26  //}
    27  
    28  func TestSampleAccounts(t *testing.T) {
    29  	MaxAccountCount := 255
    30  	for i := 0; i < MaxAccountCount; i++ {
    31  		acc := NewAccount(fmt.Sprintf("0x0170E6B713CD32904D07A55B3AF5784E0B23EB38589EBF975F0AB89E6F8D786F%02X", i))
    32  		fmt.Println(fmt.Sprintf("account address: %s, pubkey: %s, privkey: %s", acc.Address.String(), acc.PublicKey.String(), acc.PrivateKey.String()))
    33  	}
    34  }
    35  
    36  // time="2018-11-07T15:26:07+08:00" level=info msg="Sample Account" add=0x0b5d53f433b7e4a4f853a01e987f977497dda262 priv=0x0170E6B713CD32904D07A55B3AF5784E0B23EB38589EBF975F0AB89E6F8D786F00
    37  
    38  // addr=0x0b5d53f433b7e4a4f853a01e987f977497dda262
    39  // priv=0x70E6B713CD32904D07A55B3AF5784E0B23EB38589EBF975F0AB89E6F8D786F00
    40  // sig content=0x00000000000000000b5d53f433b7e4a4f853a01e987f977497dda2621234567812345678000000000000000000000000aabbccddeeff
    41  // sig=0x3045022100c3bddcbb80245eaac2ad79c6aaff46a44c9824fd3925ff779689c8e7d1c541f80220594dfa2bf76c143b6fb7c7be46cfd59e49d959d84fc0a22bd48faf63f87137db
    42  
    43  //0x00000000000000000b5d53f433b7e4a4f853a01e987f977497dda2621234567812345678000000000000000000000000aabbccddeeff
    44  //0x3045022100c3bddcbb80245eaac2ad79c6aaff46a44c9824fd3925ff779689c8e7d1c541f80220594dfa2bf76c143b6fb7c7be46cfd59e49d959d84fc0a22bd48faf63f87137db