Skip to content

Commit

Permalink
addtl test for new token holders delegation
Browse files Browse the repository at this point in the history
  • Loading branch information
pedropregueiro committed Dec 3, 2023
1 parent df26975 commit 3235dc1
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions packages/nouns-subgraph/tests/nouns-erc-721.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import {
} from '../src/nouns-erc-721';

const someAddress = Address.fromString('0x0000000000000000000000000000000000000001');
const popularDelegate = Address.fromString('0x0000000000000000000000000000000000000002');
const freshHolderAddress = Address.fromString('0x0000000000000000000000000000000000000002');
const popularDelegate = Address.fromString('0x0000000000000000000000000000000000000003');
const BLACKHOLE_ADDRESS = Address.fromString('0x0000000000000000000000000000000000000000');

const txHash = Bytes.fromI32(11);
Expand Down Expand Up @@ -136,7 +137,7 @@ describe('nouns-erc-721', () => {
assert.fieldEquals('Delegate', popularDelegate.toHexString(), 'delegatedVotes', '0');
});

test('transfer events ignore delegate changes', () => {
test('transfer events from account with delegation ignore delegate changes', () => {
const delegateChangeEvent = createDelegateChangedEvent(
txHash,
logIndex,
Expand Down Expand Up @@ -194,5 +195,31 @@ describe('nouns-erc-721', () => {
popularDelegate.toHexString(),
);
});

test('fresh new token holder self-delegates by default', () => {
const account = getOrCreateAccount(freshHolderAddress.toHexString());
account.save();

const buyNounEvent = createTransferEvent(
txHash,
logIndex,
updateBlockTimestamp,
updateBlockNumber,
BLACKHOLE_ADDRESS,
freshHolderAddress,
BIGINT_ONE,
);

handleTransfer(buyNounEvent);

assert.fieldEquals('Account', freshHolderAddress.toHexString(), 'tokenBalance', '1');

assert.fieldEquals(
'Account',
freshHolderAddress.toHexString(),
'delegate',
freshHolderAddress.toHexString(),
);
});
});
});

0 comments on commit 3235dc1

Please sign in to comment.