Skip to content

Commit

Permalink
Merge pull request #290 from aergoio/topic/integration-tests-dpos-raft
Browse files Browse the repository at this point in the history
integration tests for dpos and raft
  • Loading branch information
kroggen authored Oct 17, 2023
2 parents ba91621 + ef08e06 commit 47d4b32
Show file tree
Hide file tree
Showing 23 changed files with 369 additions and 47 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/full_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,14 @@ jobs:
if: github.event_name != 'push' || github.ref_name != 'master' || github.ref_type != 'branch'
run: go test -timeout 999s -v ./...

- name: Integration Tests
run: |
if [ -d "tests" ]; then
cd tests
./run_tests.sh
else
echo "The 'tests' folder does not exist."
fi
- name: Integration Tests - brick
run: cd tests && ./run_tests.sh brick

- name: Integration Tests - sbp
run: cd tests && ./run_tests.sh sbp

- name: Integration Tests - dpos
run: cd tests && ./run_tests.sh dpos

- name: Integration Tests - raft
run: cd tests && ./run_tests.sh raft
4 changes: 2 additions & 2 deletions contract/vm_dummy/test_files/gas_per_function.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1286,9 +1286,9 @@ function run_test(function_name, ...)

end

function deposit()
function default()
-- do nothing, only receive native aergo tokens
end

abi.register(run_test)
abi.payable(deposit)
abi.payable(default)
4 changes: 2 additions & 2 deletions contract/vm_dummy/vm_dummy_pub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ func TestGasPerFunction(t *testing.T) {

// transfer funds to the contracts
err = bc.ConnectBlock(
NewLuaTxCall("user", "contract_v2", uint64(10e18), `{"Name":"deposit"}`),
NewLuaTxCall("user", "contract_v3", uint64(10e18), `{"Name":"deposit"}`),
NewLuaTxCall("user", "contract_v2", uint64(10e18), `{"Name":"default"}`),
NewLuaTxCall("user", "contract_v3", uint64(10e18), `{"Name":"default"}`),
)
assert.NoError(t, err, "sending funds to contracts")

Expand Down
1 change: 1 addition & 0 deletions tests/bp01.id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16Uiu2HAmG4PSXYUxkPbNb7qTcEExFpgAwBrm3hB32aJXuvX2f1sd
1 change: 1 addition & 0 deletions tests/bp01.key
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
 A<��iT�B-:�1J�\�G��1�� T'��
Expand Down
Binary file added tests/bp01.pub
Binary file not shown.
1 change: 1 addition & 0 deletions tests/bp02.id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16Uiu2HAmMzncFmnpjigZJRoraToKkABvZimMUAyXf6bdrZeN7mbJ
2 changes: 2 additions & 0 deletions tests/bp02.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
 �5
&���d�f�#[k��1~� �Ľ�=��
1 change: 1 addition & 0 deletions tests/bp02.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!�˅����:^�p�B�X̾����2/���~�
1 change: 1 addition & 0 deletions tests/bp03.id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16Uiu2HAmKB7RYXe1uHNYMtkuuM2fEHxsv6P9PZ45ogJw6aZD3y7x
1 change: 1 addition & 0 deletions tests/bp03.key
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
 ⧾o�{V�IԖu�Q���7��6$M���p�G�
1 change: 1 addition & 0 deletions tests/bp03.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!`݋/�|t�i��+�յ͚��B�5mHK4[EC
39 changes: 38 additions & 1 deletion tests/common.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@

start_nodes() {

if [ "$consensus" == "sbp" ]; then
# open the aergo node in testmode
../bin/aergosvr --testmode --home ./aergo-files > logs 2> logs &
pid=$!
else
# open the 3 nodes
../bin/aergosvr --home ./node1 >> logs1 2>> logs1 &
pid1=$!
../bin/aergosvr --home ./node2 >> logs2 2>> logs2 &
pid2=$!
../bin/aergosvr --home ./node3 >> logs3 2>> logs3 &
pid3=$!
fi

# wait the node(s) to be ready
if [ "$consensus" == "sbp" ]; then
sleep 3
elif [ "$consensus" == "dpos" ]; then
sleep 5
elif [ "$consensus" == "raft" ]; then
sleep 2
fi

}

stop_nodes() {

if [ "$consensus" == "sbp" ]; then
kill $pid
else
kill $pid1 $pid2 $pid3
fi

}

get_deploy_args() {
contract_file=$1

Expand Down Expand Up @@ -27,7 +64,7 @@ get_receipt() {
set +e

while true; do
output=$(../bin/aergocli receipt get $txhash 2>&1 > receipt.json)
output=$(../bin/aergocli receipt get --port $query_port $txhash 2>&1 > receipt.json)

#echo "output: $output"

Expand Down
48 changes: 48 additions & 0 deletions tests/config-node1.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# aergo TOML Configuration File (https://github.com/toml-lang/toml)
# base configurations
enableprofile = false

[rpc]
netserviceaddr = "0.0.0.0"
netserviceport = 7845
netservicetrace = false
nstls = false
nscert = ""
nskey = ""
nsallowcors = false

[p2p]
netprotocoladdr = "127.0.0.1"
netprotocolport = 2001
npbindaddr = "0.0.0.0"
npbindport = 2001
nptls = false
npcert = ""
npkey = "bp01.key"
npaddpeers = [
#"/ip4/127.0.0.1/tcp/2001/p2p/16Uiu2HAmG4PSXYUxkPbNb7qTcEExFpgAwBrm3hB32aJXuvX2f1sd",
"/ip4/127.0.0.1/tcp/2002/p2p/16Uiu2HAmMzncFmnpjigZJRoraToKkABvZimMUAyXf6bdrZeN7mbJ",
"/ip4/127.0.0.1/tcp/2003/p2p/16Uiu2HAmKB7RYXe1uHNYMtkuuM2fEHxsv6P9PZ45ogJw6aZD3y7x"
]
npexposeself = false
npdiscoverpeers = false
npusepolaris = false
peerrole = "producer"

[blockchain]
maxblocksize = 1000000

[mempool]
showmetrics = false

[consensus]
enablebp = true

[consensus.raft]
newcluster=true
name="bp01"

[hardfork]
v2 = "0"
v3 = "10000"
v4 = "10000"
48 changes: 48 additions & 0 deletions tests/config-node2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# aergo TOML Configuration File (https://github.com/toml-lang/toml)
# base configurations
enableprofile = false

[rpc]
netserviceaddr = "0.0.0.0"
netserviceport = 8845
netservicetrace = false
nstls = false
nscert = ""
nskey = ""
nsallowcors = false

[p2p]
netprotocoladdr = "127.0.0.1"
netprotocolport = 2002
npbindaddr = "0.0.0.0"
npbindport = 2002
nptls = false
npcert = ""
npkey = "bp02.key"
npaddpeers = [
"/ip4/127.0.0.1/tcp/2001/p2p/16Uiu2HAmG4PSXYUxkPbNb7qTcEExFpgAwBrm3hB32aJXuvX2f1sd",
#"/ip4/127.0.0.1/tcp/2002/p2p/16Uiu2HAmMzncFmnpjigZJRoraToKkABvZimMUAyXf6bdrZeN7mbJ",
"/ip4/127.0.0.1/tcp/2003/p2p/16Uiu2HAmKB7RYXe1uHNYMtkuuM2fEHxsv6P9PZ45ogJw6aZD3y7x"
]
npexposeself = false
npdiscoverpeers = false
npusepolaris = false
peerrole = "producer"

[blockchain]
maxblocksize = 1000000

[mempool]
showmetrics = false

[consensus]
enablebp = true

[consensus.raft]
newcluster=true
name="bp02"

[hardfork]
v2 = "0"
v3 = "10000"
v4 = "10000"
48 changes: 48 additions & 0 deletions tests/config-node3.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# aergo TOML Configuration File (https://github.com/toml-lang/toml)
# base configurations
enableprofile = false

[rpc]
netserviceaddr = "0.0.0.0"
netserviceport = 9845
netservicetrace = false
nstls = false
nscert = ""
nskey = ""
nsallowcors = false

[p2p]
netprotocoladdr = "127.0.0.1"
netprotocolport = 2003
npbindaddr = "0.0.0.0"
npbindport = 2003
nptls = false
npcert = ""
npkey = "bp03.key"
npaddpeers = [
"/ip4/127.0.0.1/tcp/2001/p2p/16Uiu2HAmG4PSXYUxkPbNb7qTcEExFpgAwBrm3hB32aJXuvX2f1sd",
"/ip4/127.0.0.1/tcp/2002/p2p/16Uiu2HAmMzncFmnpjigZJRoraToKkABvZimMUAyXf6bdrZeN7mbJ"
#"/ip4/127.0.0.1/tcp/2003/p2p/16Uiu2HAmKB7RYXe1uHNYMtkuuM2fEHxsv6P9PZ45ogJw6aZD3y7x"
]
npexposeself = false
npdiscoverpeers = false
npusepolaris = false
peerrole = "producer"

[blockchain]
maxblocksize = 1000000

[mempool]
showmetrics = false

[consensus]
enablebp = true

[consensus.raft]
newcluster=true
name="bp03"

[hardfork]
v2 = "0"
v3 = "10000"
v4 = "10000"
File renamed without changes.
17 changes: 17 additions & 0 deletions tests/genesis-dpos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"chain_id":{
"magic":"test.chain",
"public":true,
"mainnet":false,
"consensus":"dpos"
},
"timestamp": 1559883600000000000,
"balance": {
"AmPpcKvToDCUkhT1FJjdbNvR4kNDhLFJGHkSqfjWe3QmHm96qv4R": "1000000000000000000000"
},
"bps": [
"16Uiu2HAmG4PSXYUxkPbNb7qTcEExFpgAwBrm3hB32aJXuvX2f1sd",
"16Uiu2HAmMzncFmnpjigZJRoraToKkABvZimMUAyXf6bdrZeN7mbJ",
"16Uiu2HAmKB7RYXe1uHNYMtkuuM2fEHxsv6P9PZ45ogJw6aZD3y7x"
]
}
31 changes: 31 additions & 0 deletions tests/genesis-raft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"chain_id":{
"magic":"test.chain",
"public":true,
"mainnet":false,
"consensus":"raft"
},
"timestamp": 1559883600000000000,
"balance": {
"AmPpcKvToDCUkhT1FJjdbNvR4kNDhLFJGHkSqfjWe3QmHm96qv4R": "1000000000000000000000"
},
"bps": [
],
"enterprise_bps": [
{
"name": "bp01",
"address": "/ip4/127.0.0.1/tcp/2001",
"peerid": "16Uiu2HAmG4PSXYUxkPbNb7qTcEExFpgAwBrm3hB32aJXuvX2f1sd"
},
{
"name": "bp02",
"address": "/ip4/127.0.0.1/tcp/2002",
"peerid": "16Uiu2HAmMzncFmnpjigZJRoraToKkABvZimMUAyXf6bdrZeN7mbJ"
},
{
"name": "bp03",
"address": "/ip4/127.0.0.1/tcp/2003",
"peerid": "16Uiu2HAmKB7RYXe1uHNYMtkuuM2fEHxsv6P9PZ45ogJw6aZD3y7x"
}
]
}
Loading

0 comments on commit 47d4b32

Please sign in to comment.