github.com/cheng762/platon-go@v1.8.17-0.20190529111256-7deff2d7be26/cmd/ctool/core/transactioncmd_test.go (about)

     1  package core
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestParsePKFile(t *testing.T) {
     8  	parsePkFile(pkFilePath)
     9  }
    10  
    11  func TestGenerateAccount(t *testing.T) {
    12  	generateAccount(10, pkFilePath)
    13  }
    14  
    15  // TestGetNonce will send a request to remote node
    16  /*func TestGetNonce(t *testing.T) {
    17  	parseConfigJson(configPath)
    18  	nonce := getNonce("0x60ceca9c1290ee56b98d4e160ef0453f7c40d219")
    19  	fmt.Println(nonce)
    20  }
    21  
    22  func TestSendTransaction(t *testing.T) {
    23  
    24  	parseConfigJson(configPath)
    25  
    26  	from := "0x60ceca9c1290ee56b98d4e160ef0453f7c40d219"
    27  	to := "0x3058552A64Ce86aFb57806d15Fd9612a8591b01d"
    28  	value := "100000000000000000000000000"
    29  
    30  	if !strings.HasPrefix(value, "0x") {
    31  		intValue, _ := strconv.ParseInt(value, 10, 64)
    32  		value = hexutil.EncodeBig(big.NewInt(intValue))
    33  	}
    34  
    35  	hash, err := SendTransaction(from, to, value)
    36  	if err != nil {
    37  		t.Fatalf("error %s", err.Error())
    38  	}
    39  	if hash == "" {
    40  		t.Fatalf("error get transaction hash ")
    41  	}
    42  	fmt.Printf(hash)
    43  
    44  }
    45  
    46  func TestSendRawTransaction(t *testing.T) {
    47  
    48  	parsePkFile(pkFilePath)
    49  	parseConfigJson(configPath)
    50  
    51  	hash, err := SendRawTransaction("0x9A7313f7868D9452c8d914A38340701c448072B6", "0xCF2efb592aA9FF75B5814A1211449df03B533657", "1000000", pkFilePath)
    52  	if err != nil {
    53  		t.Fatalf("send error,%s.", err.Error())
    54  	}
    55  
    56  	fmt.Printf(hash)
    57  }*/