Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fergalwalsh committed Oct 15, 2024
1 parent 81af0c1 commit 71a1bf8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
8 changes: 6 additions & 2 deletions algojig/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'


Expand Down
6 changes: 4 additions & 2 deletions algojig/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down
11 changes: 10 additions & 1 deletion gojig/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 71a1bf8

Please sign in to comment.