Skip to content

Commit d90b5f6

Browse files
authored
Merge pull request #32 from algorandfoundation/fix/acct-data
fix: allow v11 acct param fields to be set in any.account() call
2 parents 7086c0c + d60f869 commit d90b5f6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/value-generators/avm.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { asBigInt, asUint64Cls, getRandomBigInt, getRandomBytes } from '../util'
1010
type AccountContextData = Partial<AccountData['account']> & {
1111
address?: Account
1212
incentiveEligible?: boolean
13+
lastProposed?: uint64
14+
lastHeartbeat?: uint64
1315
optedAssetBalances?: Map<internal.primitives.StubUint64Compat, internal.primitives.StubUint64Compat>
1416
optedApplications?: Application[]
1517
}
@@ -57,8 +59,10 @@ export class AvmValueGenerator {
5759
}
5860

5961
const data = new AccountData()
60-
const { address, optedAssetBalances, optedApplications, incentiveEligible, ...accountData } = input ?? {}
62+
const { address, optedAssetBalances, optedApplications, incentiveEligible, lastProposed, lastHeartbeat, ...accountData } = input ?? {}
6163
data.incentiveEligible = incentiveEligible ?? false
64+
data.lastProposed = lastProposed
65+
data.lastHeartbeat = lastHeartbeat
6266
data.account = {
6367
...data.account,
6468
...accountData,

tests/state-op-codes.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ describe('State op codes', async () => {
136136
address: dummyAccount,
137137
balance: Uint64(INITIAL_BALANCE_MICRO_ALGOS + 100000),
138138
})
139+
const incentiveEligible = op.AcctParams.acctIncentiveEligible(mockAccount)
139140
const lastProposed = op.AcctParams.acctLastProposed(mockAccount)
140141
const lastHeartbeat = op.AcctParams.acctLastHeartbeat(mockAccount)
142+
expect(incentiveEligible).toEqual([false, true])
141143
expect(lastProposed).toEqual([Global.round, true])
142144
expect(lastHeartbeat).toEqual([Global.round, true])
143145
})
@@ -146,10 +148,14 @@ describe('State op codes', async () => {
146148
const mockAccount = ctx.any.account({
147149
address: dummyAccount,
148150
balance: Uint64(INITIAL_BALANCE_MICRO_ALGOS + 100000),
151+
incentiveEligible: true,
152+
lastProposed: 100,
153+
lastHeartbeat: 200,
149154
})
150-
ctx.ledger.patchAccountData(mockAccount, { lastProposed: 100, lastHeartbeat: 200 })
155+
const incentiveEligible = op.AcctParams.acctIncentiveEligible(mockAccount)
151156
const lastProposed = op.AcctParams.acctLastProposed(mockAccount)
152157
const lastHeartbeat = op.AcctParams.acctLastHeartbeat(mockAccount)
158+
expect(incentiveEligible).toEqual([true, true])
153159
expect(lastProposed).toEqual([100, true])
154160
expect(lastHeartbeat).toEqual([200, true])
155161
})

0 commit comments

Comments
 (0)