Skip to content

Commit

Permalink
add global constants
Browse files Browse the repository at this point in the history
  • Loading branch information
josemarinas committed Feb 14, 2024
1 parent cfbdb16 commit 0121488
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
4 changes: 4 additions & 0 deletions packages/subgraph/tests/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export const HALF_ETH = '500000000000000000';

export const ERC20_AMOUNT_HALF = '10000';
export const ERC20_AMOUNT_FULL = '20000';
export const ERC20_TOTAL_SUPPLY = '10';
export const ERC20_DECIMALS = '6';
export const TOKEN_SYMBOL = 'symbol';
export const TOKEN_NAME = 'name';

export const HOUR = '3600';

Expand Down
44 changes: 28 additions & 16 deletions packages/subgraph/tests/dao/dao_v1_3_0.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import {
ERC20_AMOUNT_FULL,
CONTRACT_ADDRESS,
ZERO_BYTES32,
TOKEN_NAME,
TOKEN_SYMBOL,
ERC20_TOTAL_SUPPLY,
ERC20_DECIMALS,
} from '../constants';
import {
ExtendedERC1155Balance,
Expand Down Expand Up @@ -70,8 +74,6 @@ let tokenAddress = Address.fromString(DAO_TOKEN_ADDRESS);
let daoEntityId = generateDaoEntityId(daoAddress);
let tokenEntityId = generateTokenEntityId(tokenAddress);
let balanceEntityId = generateBalanceEntityId(daoAddress, tokenAddress);
const totalSupply = '10';
const decimals = '6';

describe('handleExecuted', () => {
afterEach(() => {
Expand Down Expand Up @@ -252,10 +254,10 @@ describe('handleExecuted', () => {
beforeAll(() => {
createERC20TokenCalls(
DAO_TOKEN_ADDRESS,
totalSupply,
'name',
'symbol',
decimals
ERC20_TOTAL_SUPPLY,
TOKEN_NAME,
TOKEN_SYMBOL,
ERC20_DECIMALS
);
getBalanceOf(DAO_TOKEN_ADDRESS, DAO_ADDRESS, ERC20_AMOUNT_HALF);
getBalanceOf(DAO_TOKEN_ADDRESS, DAO_TOKEN_ADDRESS, ERC20_AMOUNT_HALF);
Expand All @@ -273,7 +275,12 @@ describe('handleExecuted', () => {

describe('ERC20 transfer action', () => {
beforeAll(() => {
createERC20TokenCalls(DAO_TOKEN_ADDRESS, totalSupply, 'name', 'symbol');
createERC20TokenCalls(
DAO_TOKEN_ADDRESS,
ERC20_TOTAL_SUPPLY,
TOKEN_NAME,
TOKEN_SYMBOL
);

getSupportsInterface(DAO_TOKEN_ADDRESS, ERC165_INTERFACE_ID, true);
getSupportsInterface(
Expand Down Expand Up @@ -321,8 +328,8 @@ describe('handleExecuted', () => {

// check ERC20Contract entity
eq('ERC20Contract', tokenEntityId, 'id', tokenEntityId);
eq('ERC20Contract', tokenEntityId, 'name', 'name');
eq('ERC20Contract', tokenEntityId, 'symbol', 'symbol');
eq('ERC20Contract', tokenEntityId, 'name', TOKEN_NAME);
eq('ERC20Contract', tokenEntityId, 'symbol', TOKEN_SYMBOL);
assert.entityCount('ERC20Contract', 1);

// check ERC20Balance entity
Expand Down Expand Up @@ -437,8 +444,8 @@ describe('handleExecuted', () => {

// check ERC20Contract entity
eq('ERC20Contract', tokenEntityId, 'id', tokenEntityId);
eq('ERC20Contract', tokenEntityId, 'name', 'name');
eq('ERC20Contract', tokenEntityId, 'symbol', 'symbol');
eq('ERC20Contract', tokenEntityId, 'name', TOKEN_NAME);
eq('ERC20Contract', tokenEntityId, 'symbol', TOKEN_SYMBOL);
assert.entityCount('ERC20Contract', 1);

// check ERC20Balance entity
Expand Down Expand Up @@ -516,7 +523,12 @@ describe('handleExecuted', () => {

describe('ERC721 action', () => {
beforeAll(() => {
createERC20TokenCalls(DAO_TOKEN_ADDRESS, totalSupply, 'name', 'symbol');
createERC20TokenCalls(
DAO_TOKEN_ADDRESS,
ERC20_TOTAL_SUPPLY,
TOKEN_NAME,
TOKEN_SYMBOL
);

getSupportsInterface(DAO_TOKEN_ADDRESS, '0x01ffc9a7', true);
getSupportsInterface(DAO_TOKEN_ADDRESS, '80ac58cd', true);
Expand Down Expand Up @@ -576,8 +588,8 @@ describe('handleExecuted', () => {

// check ERC721Contract entity
eq('ERC721Contract', tokenEntityId, 'id', tokenEntityId);
eq('ERC721Contract', tokenEntityId, 'name', 'name');
eq('ERC721Contract', tokenEntityId, 'symbol', 'symbol');
eq('ERC721Contract', tokenEntityId, 'name', TOKEN_NAME);
eq('ERC721Contract', tokenEntityId, 'symbol', TOKEN_SYMBOL);
assert.entityCount('ERC721Contract', 1);

// check ERC721Balance entity
Expand Down Expand Up @@ -683,8 +695,8 @@ describe('handleExecuted', () => {

// check ERC721Contract entity
eq('ERC721Contract', tokenEntityId, 'id', tokenEntityId);
eq('ERC721Contract', tokenEntityId, 'name', 'name');
eq('ERC721Contract', tokenEntityId, 'symbol', 'symbol');
eq('ERC721Contract', tokenEntityId, 'name', TOKEN_NAME);
eq('ERC721Contract', tokenEntityId, 'symbol', TOKEN_SYMBOL);
assert.entityCount('ERC721Contract', 1);

// check ERC721Balance entity
Expand Down

0 comments on commit 0121488

Please sign in to comment.