Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #93 from jolly-fellow/main
Browse files Browse the repository at this point in the history
Fixed bootstrap sequence
  • Loading branch information
jolly-fellow authored Jan 21, 2023
2 parents 962b774 + 6b70141 commit d437f07
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 37 deletions.
51 changes: 38 additions & 13 deletions src/dune/dune.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,22 @@ def create_snapshot(self):
print(url)

def deploy_contract(self, directory, acnt):
self.cleos_cmd(
['set', 'account', 'permission', acnt, 'active', '--add-code'])
stdout, stderr, exit_code = self.cleos_cmd(
['set', 'contract', acnt, directory])
stdout = ""
stderr = ""
exit_code = 0
count = 10
while count > 0:
self.cleos_cmd(
['set', 'account', 'permission', acnt, 'active', '--add-code'])

stdout, stderr, exit_code = self.cleos_cmd(
['set', 'contract', acnt, directory])

if exit_code:
count = count - 1
print('*** Retry')
else:
break

if exit_code == 0:
print(stdout)
Expand Down Expand Up @@ -529,8 +541,11 @@ def get_table(self, acnt, scope, tab):

@staticmethod
def features():
return ["KV_DATABASE",
return ["GET_CODE_HASH",
"CRYPTO_PRIMITIVES",
"GET_BLOCK_NUM",
"ACTION_RETURN_VALUE",
"CONFIGURABLE_WASM_LIMITS2",
"BLOCKCHAIN_PARAMETERS",
"GET_SENDER",
"FORWARD_SETCODE",
Expand All @@ -551,18 +566,28 @@ def activate_feature(self, code_name, preactivate=False):
self.deploy_contract(
'/app/reference-contracts/build/contracts/eosio.boot', 'eosio')

if code_name == "KV_DATABASE":
self.send_action(
'activate',
'eosio',
'["825ee6288fb1373eab1b5187ec2f04f6ea'
'cb39cb3a97f356a07c91622dd61d16"]',
'eosio@active')
elif code_name == "ACTION_RETURN_VALUE":
if code_name == "ACTION_RETURN_VALUE":
self.send_action('activate', 'eosio',
'["c3a6138c5061cf291310887c0b5c71'
'fcaffeab90d5deb50d3b9e687cead45071"]',
'eosio@active')
elif code_name == "GET_CODE_HASH":
self.send_action('activate', 'eosio',
'["bcd2a26394b36614fd4894241d3c451ab0f6fd110958c3423073621a70826e99"]',
'eosio@active')
elif code_name == "GET_BLOCK_NUM":
self.send_action('activate', 'eosio',
'["35c2186cc36f7bb4aeaf4487b36e57039ccf45a9136aa856a5d569ecca55ef2b"]',
'eosio@active')
elif code_name == "CRYPTO_PRIMITIVES":
self.send_action('activate', 'eosio',
'["6bcb40a24e49c26d0a60513b6aeb8551d264e4717f306b81a37a5afb3b47cedc"]',
'eosio@active')
elif code_name == "CONFIGURABLE_WASM_LIMITS2":
self.send_action('activate', 'eosio',
'["d528b9f6e9693f45ed277af93474fd47'
'3ce7d831dae2180cca35d907bd10cb40"]',
'eosio@active')
elif code_name == "BLOCKCHAIN_PARAMETERS":
self.send_action('activate', 'eosio',
'["5443fcf88330c586bc0e5f3dee10e7f'
Expand Down
2 changes: 1 addition & 1 deletion tests/test_all_options_tested.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from common import TEST_PATH

@pytest.mark.skip(reason="Missing option: --bootstrap-system,Missing option: --get-table,Missing option: --activate-feature")
@pytest.mark.skip(reason="Not implemented options make this test failed")
def test_all_options_tested():
"""Test that all the options from the output of `--help` are in the various test files."""

Expand Down
14 changes: 8 additions & 6 deletions tests/test_boostrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
--create-key
--import-dev-key
--bootstrap-system-full
--get-table
"""

import subprocess
Expand All @@ -18,17 +19,16 @@
ACCT_NAME = "myaccount"


@pytest.mark.skip(reason="because --bootstrap-system-full doesn't currently behave correctly.")
def test_booststrap():

# Remove any existing containers.
subprocess.run([DUNE_EXE,"--destroy-container"], check=True)
subprocess.run([DUNE_EXE, "--destroy-container"], check=True)

# Start the new node.
subprocess.run([DUNE_EXE,"--start",NODE_NAME], check=True)
subprocess.run([DUNE_EXE, "--start",NODE_NAME], check=True)

# Create an account.
subprocess.run([DUNE_EXE,"--create-account",ACCT_NAME], check=True)
subprocess.run([DUNE_EXE, "--create-account",ACCT_NAME], check=True)

# Create a key. Get it to a var as well.
public_key = None
Expand All @@ -48,8 +48,10 @@ def test_booststrap():
assert private_key is not None

# Import the key.
subprocess.run([DUNE_EXE,"--import-dev-key",private_key], check=True)
subprocess.run([DUNE_EXE, "--import-dev-key",private_key], check=True)

# Bootstrap the system.
subprocess.run([DUNE_EXE, "--bootstrap-system-full"], check=True)
assert False # Asserting because --bootstrap-system-full doesn't currently behave correctly.

results = subprocess.run([DUNE_EXE, "--get-table", "eosio.token", "eosio", "accounts"], check=True, stdout=subprocess.PIPE)
assert b'"rows"' in results.stdout
35 changes: 18 additions & 17 deletions tests/test_list_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,24 @@ def test_list_features():

# List of expected output lines from `dune --list-features`.
expect_list = \
[
b'KV_DATABASE',
b'ACTION_RETURN_VALUE',
b'BLOCKCHAIN_PARAMETERS',
b'GET_SENDER',
b'FORWARD_SETCODE',
b'ONLY_BILL_FIRST_AUTHORIZER',
b'RESTRICT_ACTION_TO_SELF',
b'DISALLOW_EMPTY_PRODUCER_SCHEDULE',
b'FIX_LINKAUTH_RESTRICTION',
b'REPLACE_DEFERRED',
b'NO_DUPLICATE_DEFERRED_ID',
b'ONLY_LINK_TO_EXISTING_PERMISSION',
b'RAM_RESTRICTIONS',
b'WEBAUTHN_KEY',
b'WTMSIG_BLOCK_SIGNATURES',
]
[b"GET_CODE_HASH",
b"CRYPTO_PRIMITIVES",
b"GET_BLOCK_NUM",
b"ACTION_RETURN_VALUE",
b"CONFIGURABLE_WASM_LIMITS2",
b"BLOCKCHAIN_PARAMETERS",
b"GET_SENDER",
b"FORWARD_SETCODE",
b"ONLY_BILL_FIRST_AUTHORIZER",
b"RESTRICT_ACTION_TO_SELF",
b"DISALLOW_EMPTY_PRODUCER_SCHEDULE",
b"FIX_LINKAUTH_RESTRICTION",
b"REPLACE_DEFERRED",
b"NO_DUPLICATE_DEFERRED_ID",
b"ONLY_LINK_TO_EXISTING_PERMISSION",
b"RAM_RESTRICTIONS",
b"WEBAUTHN_KEY",
b"WTMSIG_BLOCK_SIGNATURES"]

# Convert the list to a useful comparison value.
expect = b''
Expand Down

0 comments on commit d437f07

Please sign in to comment.