Skip to content

Commit

Permalink
Add pointer equivalence test
Browse files Browse the repository at this point in the history
  • Loading branch information
algochoi committed Aug 11, 2021
1 parent 16e147d commit 5f98b82
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions ledger/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,19 +392,22 @@ func TestPrepareEvalParams(t *testing.T) {
expected []bool

numAppCalls int
// Used for checking transitive pointer equality in app calls
// If there are no app calls in the group, it is set to -1
firstAppCallIndex int
}

// Create some groups with these transactions
cases := []evalTestCase{
{[]transactions.SignedTxnWithAD{payment}, []bool{false}, 0},
{[]transactions.SignedTxnWithAD{appcall1}, []bool{true}, 1},
{[]transactions.SignedTxnWithAD{payment, payment}, []bool{false, false}, 0},
{[]transactions.SignedTxnWithAD{appcall1, payment}, []bool{true, false}, 1},
{[]transactions.SignedTxnWithAD{payment, appcall1}, []bool{false, true}, 1},
{[]transactions.SignedTxnWithAD{appcall1, appcall2}, []bool{true, true}, 2},
{[]transactions.SignedTxnWithAD{appcall1, appcall2, appcall1}, []bool{true, true, true}, 3},
{[]transactions.SignedTxnWithAD{payment, appcall1, payment}, []bool{false, true, false}, 1},
{[]transactions.SignedTxnWithAD{appcall1, payment, appcall2}, []bool{true, false, true}, 2},
{[]transactions.SignedTxnWithAD{payment}, []bool{false}, 0, -1},
{[]transactions.SignedTxnWithAD{appcall1}, []bool{true}, 1, 0},
{[]transactions.SignedTxnWithAD{payment, payment}, []bool{false, false}, 0, -1},
{[]transactions.SignedTxnWithAD{appcall1, payment}, []bool{true, false}, 1, 0},
{[]transactions.SignedTxnWithAD{payment, appcall1}, []bool{false, true}, 1, 1},
{[]transactions.SignedTxnWithAD{appcall1, appcall2}, []bool{true, true}, 2, 0},
{[]transactions.SignedTxnWithAD{appcall1, appcall2, appcall1}, []bool{true, true, true}, 3, 0},
{[]transactions.SignedTxnWithAD{payment, appcall1, payment}, []bool{false, true, false}, 1, 1},
{[]transactions.SignedTxnWithAD{appcall1, payment, appcall2}, []bool{true, false, true}, 2, 0},
}

for i, param := range params {
Expand All @@ -431,6 +434,8 @@ func TestPrepareEvalParams(t *testing.T) {
require.Equal(t, res[k].TxnGroup, expGroupNoAD)
require.Equal(t, *res[k].Proto, eval.proto)
require.Equal(t, *res[k].Txn, testCase.group[k].SignedTxn)
require.Equal(t, res[k].MinTealVersion, res[testCase.firstAppCallIndex].MinTealVersion)
require.Equal(t, res[k].PooledApplicationBudget, res[testCase.firstAppCallIndex].PooledApplicationBudget)
if reflect.DeepEqual(param, config.Consensus[protocol.ConsensusV29]) {
require.Equal(t, *res[k].PooledApplicationBudget, uint64(eval.proto.MaxAppProgramCost))
} else if reflect.DeepEqual(param, config.Consensus[protocol.ConsensusFuture]) {
Expand Down Expand Up @@ -692,7 +697,7 @@ func TestEvalAppPooledBudgetWithTxnGroup(t *testing.T) {
""},
{source(16, 18), false, false,
"pc= 12 dynamic cost budget exceeded, executing keccak256: remaining budget is 700 but program cost was 781",
"dynamic cost budget exceeded, executing pushint: remaining budget is 2100 but program cost was 2101"},
"pc= 78 dynamic cost budget exceeded, executing pushint: remaining budget is 2100 but program cost was 2101"},
}

for i, param := range params {
Expand Down

0 comments on commit 5f98b82

Please sign in to comment.