Skip to content

Commit

Permalink
AVM: Require every global field to get tested (#5864)
Browse files Browse the repository at this point in the history
  • Loading branch information
jannotti committed Dec 11, 2023
1 parent 4b872f2 commit 548fbb4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion data/transactions/logic/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,7 @@ const globalV9TestProgram = globalV8TestProgram + `
const globalV10TestProgram = globalV9TestProgram + `
global AssetCreateMinBalance; int 1001; ==; &&
global AssetOptInMinBalance; int 1001; ==; &&
global GenesisHash; len; int 32; ==; &&
`

func TestGlobal(t *testing.T) {
Expand All @@ -1254,12 +1255,16 @@ func TestGlobal(t *testing.T) {
7: {CallerApplicationAddress, globalV7TestProgram},
8: {CallerApplicationAddress, globalV8TestProgram},
9: {CallerApplicationAddress, globalV9TestProgram},
10: {AssetOptInMinBalance, globalV10TestProgram},
10: {GenesisHash, globalV10TestProgram},
}
// tests keys are versions so they must be in a range 1..AssemblerMaxVersion plus zero version
require.LessOrEqual(t, len(tests), AssemblerMaxVersion+1)
require.Len(t, globalFieldSpecs, int(invalidGlobalField))

// ensure we are testing everything
require.Equal(t, tests[AssemblerMaxVersion].lastField, invalidGlobalField-1,
"did you add a new global field?")

ledger := NewLedger(nil)
addr, err := basics.UnmarshalChecksumAddress(testAddr)
require.NoError(t, err)
Expand Down

0 comments on commit 548fbb4

Please sign in to comment.