Skip to content

Commit

Permalink
merge master 75a6288
Browse files Browse the repository at this point in the history
  • Loading branch information
guo-li-hua committed Jul 17, 2019
2 parents c31222a + 75a6288 commit 788ded9
Show file tree
Hide file tree
Showing 90 changed files with 1,549 additions and 883 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -79,3 +79,4 @@ cmd/gptn/
gptn/
dag/transactions.rlp.new
dag/transactions.rlp
ofile
41 changes: 40 additions & 1 deletion .travis.yml
Expand Up @@ -16,6 +16,7 @@ env:
- DEPOSIT_DIR=deposit
- GAS_TOKEN_DIR=gasToken
- MEDIATOR_VOTE_DIR=meidatorvote
- APPLICATION_DIR=application
- LOG_NAME=log.html
- REPORT_NAME=report.html
########## control testcase ##############
Expand All @@ -30,6 +31,7 @@ env:
- IS_RUN_VOTE=true
- IS_RUN_GASTOKEN=true
- IS_RUN_MEDIATOR_VOTE=true
- IS_RUN_APPLICATION=true
- GO111MODULE=on
- IS_UPLOAD=true
# - 'SFTP_KEY=[base64-encoded-rsa-key]'
Expand Down Expand Up @@ -241,13 +243,50 @@ matrix:
- sudo -H apt-get install expect
- sudo -H apt-get install lftp
- chmod +x bdd/upload2Ftp.sh
- os: linux
dist: xenial
go: 1.12.5
env: application_bdd
script:
- go build ./cmd/gptn
- mkdir bdd/application/node
- cp gptn bdd/application/node
- if [ $IS_RUN_APPLICATION == 'true' ]; then
cd ./bdd/application;
chmod +x ./init.sh;
./init.sh;
sleep 15;
python -m robot.run -d ${BDD_LOG_PATH}/${APPLICATION_DIR} .;
fi
after_script:
- killall gptn
- sleep 2
- cd ${BASE_DIR}
- zip -j ./bdd/logs/application_log.zip ./bdd/application/node/log/*
- |
if [ $IS_UPLOAD == 'true' ]; then
# uplaod all log
./bdd/upload2Ftp.sh ${FTP_PWD} ${TRAVIS_BRANCH};
echo "The path of all bdd log in vsftpd is 'ftp://47.74.209.46"
fi
install:
- sudo -H pip install --upgrade pip
- sudo -H pip install robotframework==2.8.5
- sudo -H pip install requests
- sudo -H pip install robotframework-requests
- sudo -H pip install demjson
- sudo -H pip install pexpect
- sudo -H apt-get install expect
- sudo -H apt-get install lftp
- chmod +x bdd/upload2Ftp.sh
before_install:
- go get -u github.com/palletone/adaptor
- go get -u github.com/palletone/btc-adaptor
- go get -u github.com/palletone/eth-adaptor
- source ./build/goget_by_version.sh
#- source ./gomockgen.sh



addons:
apt:
update: true
Expand Down
43 changes: 43 additions & 0 deletions bdd/application/ProofOfExistence/proofOfExistence.robot
@@ -0,0 +1,43 @@
*** Settings ***
Test Setup beforeVote
Library Collections
Resource ../pubVariables.robot
Resource ../pubFuncs.robot
Resource ../setups.robot

*** Test Cases ***
mediatorvote
Given user unlock its account succeed
When create proof existence
and wait transaction packaged
Then check proof existence

*** Keywords ***
user unlock its account succeed
${respJson}= unlockAccount ${userAccount}
log ${respJson}
Dictionary Should Contain Key ${respJson} result
Should Be Equal ${respJson["result"]} ${true}

create proof existence
Log create proof existence
${args}= Create List
${params}= Create List ${userAccount} ${maindata} ${extradata} ${reference} ${fee}
${resp}= sendRpcPost ${createProofExistence} ${params} create proof existence
${res} set variable ${resp["result"]}
log ${res} INFO

wait transaction packaged
Log wait for transaction being packaged
Sleep 15

check proof existence
Log check proof existence
${args}= Create List
${params}= Create List ${reference}
${resp}= sendRpcPost ${checkProofExistence} ${params} check proof existence
${res}= Get From Dictionary ${resp} result
${refs}= Get From List ${res} 0
${ref} set variable ${refs["reference"]}
Should Be Equal ${ref} ${reference}
log ${ref} INFO
36 changes: 36 additions & 0 deletions bdd/application/init.sh
@@ -0,0 +1,36 @@
#!/bin/bash
#pkill gptn
#tskill gptn
#cd ../../cmd/gptn && go build
cd ../../
#rm -rf ./bdd/application/node*
#cp ./cmd/gptn/gptn ./bdd/application/node
cd ./bdd/application/node
chmod +x gptn

# new genesis
./gptn newgenesis "" fasle << EOF
y
1
1
EOF

# edit toml file
tomlFile="ptn-config.toml"
if [ -e "$tomlFile" ]; then
#file already exist, modify
sed -i "s/HTTPPort = 8545/HTTPPort = 8600/g" $tomlFile

else
#file not found, new file
echo "no $tomlFile"
exit -1
fi

# gptn init
./gptn init << EOF
1
EOF

# start gptn
nohup ./gptn &
53 changes: 53 additions & 0 deletions bdd/application/pubFuncs.robot
@@ -0,0 +1,53 @@
*** Settings ***
Resource pubVariables.robot

*** Keywords ***
newAccount
${params}= Create List 1
${respJson}= sendRpcPost personal_newAccount ${params} newAccount
Dictionary Should Contain Key ${respJson} result
[Return] ${respJson["result"]}

transferPTN
[Arguments] ${to}
${params}= Create List ${tokenHolder} ${to} ${amount} ${fee} ${null}
... ${pwd}
${respJson}= sendRpcPost ${transerferPTNMethod} ${params} transferPTN
Dictionary Should Contain Key ${respJson} result

getBalance
[Arguments] ${addr}
${params}= Create List ${addr}
${respJson}= sendRpcPost ${getBalanceMethod} ${params} getBalance
Dictionary Should Contain Key ${respJson} result
Dictionary Should Contain Key ${respJson["result"]} PTN
[Return] ${respJson["result"]["PTN"]}

unlockAccount
[Arguments] ${addr}
${params}= Create List ${addr} ${pwd} ${600000000}
${respJson}= sendRpcPost ${unlockAccountMethod} ${params} unlockAccount
[Return] ${respJson}

sendRpcPost
[Arguments] ${method} ${params} ${alias}
${header}= Create Dictionary Content-Type application/json
${data} Create Dictionary jsonrpc=2.0 method=${method} params=${params} id=1
Create Session ${alias} http://127.0.0.1:8600
${resp} Post Request ${alias} http://127.0.0.1:8600 data=${data} headers=${header}
${respJson} To Json ${resp.content}
[Return] ${respJson}

queryTokenHolder
${args}= Create List
${params}= Create List
${respJson}= sendRpcPost ${personalListAccountsMethod} ${params} queryTokenHolder
Dictionary Should Contain Key ${respJson} result
${accounts}= Get From Dictionary ${respJson} result
${firstAddr}= Get From List ${accounts} 0
Set Global Variable ${tokenHolder} ${firstAddr}
log ${tokenHolder}

wait for transaction being packaged
Log wait for transaction being packaged
Sleep 6
22 changes: 22 additions & 0 deletions bdd/application/pubVariables.robot
@@ -0,0 +1,22 @@
*** Settings ***
Library RequestsLibrary

*** Variables ***
${host} http://localhost:8600/
# methods
${transerferPTNMethod} wallet_transferPtn
${getBalanceMethod} wallet_getBalance
${personalListAccountsMethod} personal_listAccounts
${unlockAccountMethod} personal_unlockAccount
${createProofExistence} wallet_createProofOfExistenceTx
${checkProofExistence} wallet_getProofOfExistencesByRef
# common variables
${userAccount} ${null}
${tokenHolder} ${null}
${maindata} maindata
${extradata} extradata
${reference} A
${amount} 10000
${fee} 1
${pwd} 1
${duration} 600000000
23 changes: 23 additions & 0 deletions bdd/application/setups.robot
@@ -0,0 +1,23 @@
*** Settings ***
Resource pubVariables.robot
Resource pubFuncs.robot
Library Collections

*** Keywords ***
beforeVote
queryTokenHolder
newAccounts
transferPTNToUser

newAccounts
# create a user for the poll
${user1}= newAccount
Set Global Variable ${userAccount} ${user1}

transferPTNToUser
# transfer PTN to user for the poll
transferPTN ${userAccount}
Log wait for tx being packaged into unit
Sleep 5 # should sleep, because transaction has not been packaged into unit
${balance}= getBalance ${userAccount}
Should Be Equal ${balance} ${amount}
2 changes: 1 addition & 1 deletion bdd/light/testcases/bddstart.sh
Expand Up @@ -36,7 +36,7 @@ sleep 5
#ptn.syncUTXOByAddr("P19wzjSAfVKRY84pPQMsqJSxeVK7oTYEiXt") in light node5
syncutxocommand=`./gptn --exec "ptn.syncUTXOByAddr($account5)" attach node_test5/palletone/gptn5.ipc`
syncutxoinfo=`echo $syncutxocommand`
value="\"OK\""
value="\"ok\""
echo $syncutxoinfo
if [ $syncutxoinfo = $value ];then
echo "============syncUTXOByAddr account5 ok============"
Expand Down
7 changes: 6 additions & 1 deletion cmd/gptn/config.go
Expand Up @@ -45,6 +45,8 @@ import (
"github.com/palletone/go-palletone/ptnjson"
"github.com/palletone/go-palletone/statistics/dashboard"
"gopkg.in/urfave/cli.v1"
"bytes"
"github.com/palletone/go-palletone/common/crypto"
)

const defaultConfigPath = "./ptn-config.toml"
Expand Down Expand Up @@ -256,7 +258,10 @@ func makeConfigNode(ctx *cli.Context, isInConsole bool) (*node.Node, FullConfig)
adaptorPtnConfig(&cfg)

utils.SetPtnConfig(ctx, stack, &cfg.Ptn)

if bytes.Equal( cfg.Ptn.CryptoLib,[]byte{1,1}){
fmt.Println("Use GM crypto lib")
crypto.MyCryptoLib=&crypto.CryptoGm{}
}
if ctx.GlobalIsSet(utils.EthStatsURLFlag.Name) {
cfg.Ptnstats.URL = ctx.GlobalString(utils.EthStatsURLFlag.Name)
}
Expand Down
1 change: 1 addition & 0 deletions cmd/gptn/genesis_json.go
Expand Up @@ -63,6 +63,7 @@ var (
ArgsUsage: "<genesisJsonPath> <openStdout>",
Flags: []cli.Flag{
GenesisJsonPathFlag,
utils.CryptoLibFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Description: `
Expand Down
2 changes: 1 addition & 1 deletion cmd/gptn/main.go
Expand Up @@ -87,7 +87,7 @@ var (
utils.MaxPeersFlag,
utils.MaxPendingPeersFlag,
utils.EtherbaseFlag,
utils.GasPriceFlag,
utils.CryptoLibFlag,
utils.MinerThreadsFlag,
utils.MiningEnabledFlag,
//utils.TargetGasLimitFlag,
Expand Down
22 changes: 12 additions & 10 deletions cmd/utils/flags.go
Expand Up @@ -21,7 +21,7 @@ import (
"crypto/ecdsa"
"fmt"
"io/ioutil"
"math/big"

"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -54,6 +54,7 @@ import (
"github.com/palletone/go-palletone/statistics/metrics"
"github.com/palletone/go-palletone/statistics/ptnstats"
"gopkg.in/urfave/cli.v1"
"encoding/hex"
)

var (
Expand Down Expand Up @@ -295,10 +296,10 @@ var (
Usage: "Public address for block mining rewards (default = first account created)",
Value: "0",
}
GasPriceFlag = BigFlag{
Name: "gasprice",
Usage: "Minimal gas price to accept for mining a transactions",
Value: ptn.DefaultConfig.GasPrice,
CryptoLibFlag = cli.StringFlag{
Name: "cryptolib",
Usage: "set crypto lib,1st byte sign algorithm: 0,ECDSA-S256;1,GM-SM2 2ed byte hash algorithm: 0,SHA3;1,GM-SM3",
Value: hex.EncodeToString( ptn.DefaultConfig.CryptoLib),
}
ExtraDataFlag = cli.StringFlag{
Name: "extradata",
Expand Down Expand Up @@ -1125,8 +1126,9 @@ func SetPtnConfig(ctx *cli.Context, stack *node.Node, cfg *ptn.Config) {
if ctx.GlobalIsSet(ExtraDataFlag.Name) {
cfg.ExtraData = []byte(ctx.GlobalString(ExtraDataFlag.Name))
}
if ctx.GlobalIsSet(GasPriceFlag.Name) {
cfg.GasPrice = GlobalBig(ctx, GasPriceFlag.Name)
if ctx.GlobalIsSet(CryptoLibFlag.Name) {
t:= ctx.GlobalString(CryptoLibFlag.Name)
cfg.CryptoLib,_ =hex.DecodeString(t)
}
if ctx.GlobalIsSet(VMEnableDebugFlag.Name) {
// TODO(fjl): force-enable this in --dev mode
Expand Down Expand Up @@ -1159,9 +1161,9 @@ func SetPtnConfig(ctx *cli.Context, stack *node.Node, cfg *ptn.Config) {
}
log.Info("Using developer account", "address", developer.Address)

if !ctx.GlobalIsSet(GasPriceFlag.Name) {
cfg.GasPrice = big.NewInt(1)
}
//if !ctx.GlobalIsSet(GasPriceFlag.Name) {
// cfg.GasPrice = big.NewInt(1)
//}
}
// TODO(fjl): move trie cache generations into config
if gen := ctx.GlobalInt(TrieCacheGenFlag.Name); gen > 0 {
Expand Down
Binary file removed common/crypto/gmsm/sm2/ofile
Binary file not shown.
4 changes: 2 additions & 2 deletions common/util/rlphash_test.go
Expand Up @@ -3,12 +3,12 @@ package util
import "testing"

type A struct {
Data uint
Data uint32
}

func TestRlpHash(t *testing.T) {
for i := 0; i < 10; i++ {
a := &A{Data: uint(i)}
a := &A{Data: uint32(i)}
hash := RlpHash(a)
t.Logf("Number:%d,Hash:%x,Hash2:%x", i, hash, RlpHash(i))
}
Expand Down

0 comments on commit 788ded9

Please sign in to comment.