diff --git a/algojig/exceptions.py b/algojig/exceptions.py index 65b9400..6261154 100644 --- a/algojig/exceptions.py +++ b/algojig/exceptions.py @@ -18,8 +18,12 @@ def __init__(self, result, txn_id, error, source) -> None: super().__init__(result) def __str__(self) -> str: - line = self.source['line'] - line_no = self.source['line_no'] + try: + line = self.source['line'] + line_no = self.source['line_no'] + except Exception: + line_no = "" + line = "" return f'{self.error}: L{line_no}: {line}' diff --git a/algojig/ledger.py b/algojig/ledger.py index bfd1dd3..9bb2994 100644 --- a/algojig/ledger.py +++ b/algojig/ledger.py @@ -29,6 +29,7 @@ def __init__(self): self.raw_accounts = {} self.creator_sk, self.creator = generate_account() self.set_account_balance(self.creator, 100_000_000) + self.next_timestamp = 1000 def set_account_balance(self, address, balance, asset_id=0, frozen=False): if address not in self.accounts: @@ -149,8 +150,8 @@ def box_exists(self, app_id, key): def get_raw_account(self, address): return self.raw_accounts.get(address, {}) - def eval_transactions(self, transactions, block_timestamp=1000): - self.init_ledger_db(block_timestamp) + def eval_transactions(self, transactions, block_timestamp=None): + self.init_ledger_db(block_timestamp or self.next_timestamp) self.write() self.write_transactions(transactions) try: @@ -196,6 +197,7 @@ def eval_transactions(self, transactions, block_timestamp=1000): result['accounts'][encode_address(a)] = result['accounts'].pop(a) self.update_accounts(result['accounts']) self.update_boxes(result['boxes']) + self.last_block = result['block'] return result['block'] def write_transactions(self, transactions): diff --git a/gojig/main.go b/gojig/main.go index 26f9adf..b19d23f 100644 --- a/gojig/main.go +++ b/gojig/main.go @@ -231,6 +231,15 @@ func evalTransactions(fn string) { accounts[address] = data } + // Find accounts of all apps + for i := 0; uint64(i) < block.TxnCounter; i++ { + appAddress := basics.AppIndex(i).Address() + data, _, algo, err := ledger.LookupLatest(appAddress) + if err == nil && algo.GreaterThan(basics.MicroAlgos{}) { + accounts[appAddress] = data + } + } + // Find all box keys keys, err := ledger.LookupKeysByPrefix(block.Round(), "bx:", math.MaxUint64) if err != nil { @@ -307,7 +316,7 @@ func encode(obj interface{}) ([]byte, error) { func makeJigLedger(fn string, initAccounts map[basics.Address]basics.AccountData) *ledger.Ledger { var poolData basics.AccountData - poolData.MicroAlgos.Raw = 123456789 + poolData.MicroAlgos.Raw = 10_000_000_000_000_000 initAccounts[rewardsPool] = poolData var feeData basics.AccountData diff --git a/setup.py b/setup.py index 5d4ecf7..7787290 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup PACKAGE_NAME = "algojig" -VERSION = "0.0.2" +VERSION = "0.0.3" DESCRIPTION = "A testing jig for the Algorand Virtual Machine." KEYWORDS = "algorand teal tealish" LICENSE = "MIT"