From fb76ca92d4b3a85441987c37916d90b66b6d52c1 Mon Sep 17 00:00:00 2001 From: Captain Date: Fri, 28 Jan 2022 00:37:36 +0000 Subject: [PATCH] DERO-HE STARGATE Testnet Release41 --- config/config.go | 2 +- config/version.go | 2 +- dvm/dvm.go | 1 + dvm/dvm_store.go | 10 ++-- tests/normal/name_test/run_test.sh | 78 ++++++++++++++++++++++++++++++ walletapi/transaction_build.go | 2 +- 6 files changed, 87 insertions(+), 8 deletions(-) create mode 100755 tests/normal/name_test/run_test.sh diff --git a/config/config.go b/config/config.go index fd03621..211f7d5 100644 --- a/config/config.go +++ b/config/config.go @@ -107,7 +107,7 @@ var Mainnet = CHAIN_CONFIG{Name: "mainnet", } var Testnet = CHAIN_CONFIG{Name: "testnet", // testnet will always have last 3 bytes 0 - Network_ID: uuid.FromBytesOrNil([]byte{0x59, 0xd7, 0xf7, 0xe9, 0xdd, 0x48, 0xd5, 0xfd, 0x13, 0x0a, 0xf6, 0xe0, 0x79, 0x00, 0x00, 0x00}), + Network_ID: uuid.FromBytesOrNil([]byte{0x59, 0xd7, 0xf7, 0xe9, 0xdd, 0x48, 0xd5, 0xfd, 0x13, 0x0a, 0xf6, 0xe0, 0x80, 0x00, 0x00, 0x00}), GETWORK_Default_Port: 10100, P2P_Default_Port: 40401, RPC_Default_Port: 40402, diff --git a/config/version.go b/config/version.go index eecf813..1010cf6 100644 --- a/config/version.go +++ b/config/version.go @@ -20,4 +20,4 @@ import "github.com/blang/semver/v4" // right now it has to be manually changed // do we need to include git commitsha?? -var Version = semver.MustParse("3.4.105-0.DEROHE.STARGATE+18012022") +var Version = semver.MustParse("3.4.106-0.DEROHE.STARGATE+18012022") diff --git a/dvm/dvm.go b/dvm/dvm.go index 4421fbb..318b82f 100644 --- a/dvm/dvm.go +++ b/dvm/dvm.go @@ -37,6 +37,7 @@ type Vtype int // the numbers start from 3 to avoid collisions and can go max upto 0x7f before collision occur const ( + None Vtype = 0x0 Invalid Vtype = 0x3 // default is invalid Uint64 Vtype = 0x4 // uint64 data type String Vtype = 0x5 // string diff --git a/dvm/dvm_store.go b/dvm/dvm_store.go index 18552aa..0466172 100644 --- a/dvm/dvm_store.go +++ b/dvm/dvm_store.go @@ -186,7 +186,7 @@ func (dkey DataKey) MarshalBinaryPanic() (ser []byte) { func (v Variable) Length() (length int64) { switch v.Type { - case Invalid: + case Invalid, None: return case Uint64: var buf [binary.MaxVarintLen64]byte @@ -203,7 +203,7 @@ func (v Variable) Length() (length int64) { // these are used by lowest layers func (v Variable) MarshalBinary() (data []byte, err error) { switch v.Type { - case Invalid: + case Invalid, None: return case Uint64: var buf [binary.MaxVarintLen64]byte @@ -212,7 +212,7 @@ func (v Variable) MarshalBinary() (data []byte, err error) { case String: data = append(data, ([]byte(v.ValueString))...) // string default: - panic("unknown variable type not implemented") + panic("unknown variable type not implemented2") } data = append(data, byte(v.Type)) // add object type return @@ -231,7 +231,7 @@ func (v *Variable) UnmarshalBinary(buf []byte) (err error) { } switch Vtype(buf[len(buf)-1]) { - case Invalid: + case Invalid, None: return fmt.Errorf("Invalid cannot be deserialized") case Uint64: v.Type = Uint64 @@ -247,7 +247,7 @@ func (v *Variable) UnmarshalBinary(buf []byte) (err error) { return nil default: - panic("unknown variable type not implemented") + panic("unknown variable type not implemented3") } return diff --git a/tests/normal/name_test/run_test.sh b/tests/normal/name_test/run_test.sh new file mode 100755 index 0000000..e528c4c --- /dev/null +++ b/tests/normal/name_test/run_test.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +# set -x # to enable debug and verbose printing of each and every command + +CURDIR=`/bin/pwd` +BASEDIR=$(dirname $0) +ABSPATH=$(readlink -f $0) +ABSDIR=$(dirname $ABSPATH) + + +command -v curl >/dev/null 2>&1 || { echo "I require curl but it's not installed. Aborting." >&2; exit 1; } +command -v jq >/dev/null 2>&1 || { echo "I require jq but it's not installed. Aborting." >&2; exit 1; } + + +daemon_rpc_port="20000" # daemon rpc is listening on this port + +# we have number of wallets listening at ports from 30000 +# we will be using 3 wallets, named owner, user1,user2 +owner_rpc_port="30000" +user1_rpc_port="30001" +user2_rpc_port="30002" + +owner_address=$(curl --silent http://127.0.0.1:$owner_rpc_port/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"getaddress"}' -H 'Content-Type: application/json'| jq -r ".result.address") +user1_address=$(curl --silent http://127.0.0.1:$user1_rpc_port/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"getaddress"}' -H 'Content-Type: application/json'| jq -r ".result.address") +player2_address=$(curl --silent http://127.0.0.1:$user2_rpc_port/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"getaddress"}' -H 'Content-Type: application/json'| jq -r ".result.address") + + +function balance(){ + curl --silent http://127.0.0.1:$1/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"getbalance"}' -H 'Content-Type: application/json'| jq -r ".result.balance" +} + + + +echo "SC owner address" $owner_address +echo "user1 address" $user1_address +echo "user2 address" $user2_address + + +# echo -n "wallet1 sending dero to 2 wallets txid " +# curl --silent http://127.0.0.1:$user1_rpc_port/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"transfer","params":{ "transfers":[{"amount":10000,"destination":"'"$player2_address"'"},{"amount":10000,"destination":"'"$owner_address"'"}] }}' -H 'Content-Type: application/json' | jq -r ".result.txid" +# exit 0 + +# use owner wallet to load/install an lotter sc to chain +#scid=$(curl --silent --request POST --data-binary @nameservice.bas http://127.0.0.1:$owner_rpc_port/install_sc| jq -r ".txid") +scid="0000000000000000000000000000000000000000000000000000000000000001" +echo "Name Service SCID" $scid + +sleep 1 + + +#curl --silent http://127.0.0.1:$daemon_rpc_port/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"getsc","params":{ "scid":"'"$scid"'" , "code":false, "keysstring":["deposit_count"]}}' -H 'Content-Type: application/json' + +username="user11" +echo -n "wallet1 Registering '$username' txid " +curl --silent http://127.0.0.1:$user1_rpc_port/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"scinvoke","params":{"scid":"'"$scid"'","ringsize":2, "sc_rpc":[{"name":"entrypoint","datatype":"S","value":"Register"}, {"name":"name","datatype":"S","value":"'"$username"'" }] }}' -H 'Content-Type: application/json' | jq -r ".result.txid" +sleep 2 + +echo -n $username "registeration result " +curl --silent http://127.0.0.1:$daemon_rpc_port/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"nametoaddress","params":{"name":"'"$username"'" }}' -H 'Content-Type: application/json' | jq -r ".result.address" + + + +echo "wallet1 DERO balance before transfer" $(balance $user1_rpc_port) + +echo -n "wallet2 sending DERO to wallet1 using name txid " +curl --silent http://127.0.0.1:$user2_rpc_port/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"transfer","params":{ "transfers":[{"amount":10000,"destination":"'"$username"'"}] }}' -H 'Content-Type: application/json' | jq -r ".result.txid" +sleep 2 +echo "wallet1 DERO balance after transfer" $(balance $user1_rpc_port) + +if [[ $(balance $user1_rpc_port) -gt 800000 ]] +then + exit 0 +else + exit 1 +fi + + + diff --git a/walletapi/transaction_build.go b/walletapi/transaction_build.go index 323e5f4..7743953 100644 --- a/walletapi/transaction_build.go +++ b/walletapi/transaction_build.go @@ -136,7 +136,7 @@ rebuild_tx: value := transfers[t].Amount burn_value := transfers[t].Burn if fees == 0 && asset.SCID.IsZero() && !fees_done { - fees = fees + uint64(len(transfers)+2)* uint64((float64(config.FEE_PER_KB) * float64(w.GetFeeMultiplier() ))) + fees = fees + uint64(len(transfers)+2)*uint64((float64(config.FEE_PER_KB)*float64(w.GetFeeMultiplier()))) if data, err := scdata.MarshalBinary(); err != nil { panic(err) } else {