test: remove all matchstick tests (#233)
* test: remove all matchstick tests. * test: remove testing step in the subgraph workflow.
This commit is contained in:
parent
3da5666f09
commit
eb2a765803
|
|
@ -36,5 +36,3 @@ jobs:
|
|||
- name: Build Subgraph
|
||||
run: yarn build
|
||||
|
||||
- name: Test Subgraph
|
||||
run: yarn test
|
||||
|
|
|
|||
|
|
@ -126,7 +126,3 @@ Finally, you can generate the build that is going to be deployed to the Hosted S
|
|||
The command that should be used for re-deployment purposes is no different than the one that is used to deploy subgraphs in the first place (remember to replace the access token and the github_username/subgraph_name parts):
|
||||
|
||||
`graph deploy --product hosted-service --deploy-key YOUR_ACCESS_TOKEN --version-lable v0.0.1 YOUR_GITHUB_USERNAME/SUBGRAPH_NAME_ON_HOSTED_SERVICE`
|
||||
|
||||
## Testing
|
||||
|
||||
You can run the unit tests found in `./tests/` with `yarn test` or `npm run test`.
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
testsFolder: tests/matchstick/
|
||||
manifestPath: subgraph.yaml
|
||||
|
|
@ -7,14 +7,10 @@
|
|||
"create-local": "graph create --node http://localhost:8020/ FleekNFA",
|
||||
"remove-local": "graph remove --node http://localhost:8020/ FleekNFA",
|
||||
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 FleekNFA",
|
||||
"test": "graph test",
|
||||
"compile": "cd ../contracts && yarn && yarn compile && cd ../subgraph && yarn codegen"
|
||||
},
|
||||
"dependencies": {
|
||||
"@graphprotocol/graph-cli": "0.37.2",
|
||||
"@graphprotocol/graph-ts": "0.29.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"matchstick-as": "0.5.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"version": "0.5.4",
|
||||
"timestamp": 1679061942846
|
||||
}
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
import {
|
||||
assert,
|
||||
describe,
|
||||
test,
|
||||
clearStore,
|
||||
beforeAll,
|
||||
afterAll,
|
||||
} from 'matchstick-as/assembly/index';
|
||||
import { BigInt } from '@graphprotocol/graph-ts';
|
||||
import {
|
||||
createNewAccessPointEvent,
|
||||
createNewChangeAccessPointCreationStatus,
|
||||
handleChangeAccessPointCreationStatusList,
|
||||
handleNewAccessPoints,
|
||||
USER_ONE,
|
||||
USER_TWO,
|
||||
} from '../helpers/utils';
|
||||
import {
|
||||
ChangeAccessPointCreationStatus,
|
||||
NewAccessPoint,
|
||||
} from '../../../generated/FleekNFA/FleekNFA';
|
||||
|
||||
describe('Change Access Point Creation Status tests', () => {
|
||||
beforeAll(() => {
|
||||
// New Access Points
|
||||
const newAccessPoints: NewAccessPoint[] = [];
|
||||
|
||||
// User One has two access points: one for tokenId 0 and one for tokenId 1
|
||||
newAccessPoints.push(
|
||||
createNewAccessPointEvent(0, 'firstAP', BigInt.fromI32(0), USER_ONE)
|
||||
);
|
||||
newAccessPoints.push(
|
||||
createNewAccessPointEvent(1, 'secondAP', BigInt.fromI32(1), USER_ONE)
|
||||
);
|
||||
|
||||
// User Two has one access point for tokenId 0
|
||||
newAccessPoints.push(
|
||||
createNewAccessPointEvent(2, 'thirdAP', BigInt.fromI32(0), USER_TWO)
|
||||
);
|
||||
handleNewAccessPoints(newAccessPoints);
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
clearStore();
|
||||
});
|
||||
|
||||
describe('Assertions', () => {
|
||||
test('Check the `creationStatus` field of each access point entity', () => {
|
||||
assert.fieldEquals('AccessPoint', 'firstAP', 'creationStatus', 'DRAFT');
|
||||
assert.fieldEquals('AccessPoint', 'secondAP', 'creationStatus', 'DRAFT');
|
||||
assert.fieldEquals('AccessPoint', 'thirdAP', 'creationStatus', 'DRAFT');
|
||||
});
|
||||
|
||||
test('Check the `creationStatus` field of each access point entity after changing it', () => {
|
||||
// New Access Points
|
||||
const changeAccessPointCreationStatusList: ChangeAccessPointCreationStatus[] =
|
||||
[];
|
||||
|
||||
// User One has two access points: one for tokenId 0 and one for tokenId 1
|
||||
changeAccessPointCreationStatusList.push(
|
||||
createNewChangeAccessPointCreationStatus(
|
||||
0,
|
||||
'firstAP',
|
||||
BigInt.fromI32(0),
|
||||
1,
|
||||
USER_ONE
|
||||
)
|
||||
);
|
||||
changeAccessPointCreationStatusList.push(
|
||||
createNewChangeAccessPointCreationStatus(
|
||||
0,
|
||||
'secondAP',
|
||||
BigInt.fromI32(1),
|
||||
1,
|
||||
USER_ONE
|
||||
)
|
||||
);
|
||||
|
||||
// User Two has one access point for tokenId 0
|
||||
changeAccessPointCreationStatusList.push(
|
||||
createNewChangeAccessPointCreationStatus(
|
||||
0,
|
||||
'thirdAP',
|
||||
BigInt.fromI32(0),
|
||||
1,
|
||||
USER_TWO
|
||||
)
|
||||
);
|
||||
|
||||
handleChangeAccessPointCreationStatusList(
|
||||
changeAccessPointCreationStatusList
|
||||
);
|
||||
|
||||
assert.fieldEquals(
|
||||
'AccessPoint',
|
||||
'firstAP',
|
||||
'creationStatus',
|
||||
'APPROVED'
|
||||
);
|
||||
assert.fieldEquals(
|
||||
'AccessPoint',
|
||||
'secondAP',
|
||||
'creationStatus',
|
||||
'APPROVED'
|
||||
);
|
||||
assert.fieldEquals(
|
||||
'AccessPoint',
|
||||
'thirdAP',
|
||||
'creationStatus',
|
||||
'APPROVED'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
import {
|
||||
assert,
|
||||
describe,
|
||||
test,
|
||||
clearStore,
|
||||
beforeAll,
|
||||
afterAll,
|
||||
} from 'matchstick-as/assembly/index';
|
||||
import { BigInt } from '@graphprotocol/graph-ts';
|
||||
import {
|
||||
createNewAccessPointEvent,
|
||||
createNewChangeAccessPointNameVerify,
|
||||
handleChangeAccessPointNameVerifies,
|
||||
handleNewAccessPoints,
|
||||
USER_ONE,
|
||||
USER_TWO,
|
||||
} from '../helpers/utils';
|
||||
import {
|
||||
ChangeAccessPointNameVerify,
|
||||
NewAccessPoint,
|
||||
} from '../../../generated/FleekNFA/FleekNFA';
|
||||
|
||||
describe('Change Access Point Name Verify tests', () => {
|
||||
beforeAll(() => {
|
||||
// New Access Points
|
||||
const newAccessPoints: NewAccessPoint[] = [];
|
||||
|
||||
// User One has two access points: one for tokenId 0 and one for tokenId 1
|
||||
newAccessPoints.push(
|
||||
createNewAccessPointEvent(0, 'firstAP', BigInt.fromI32(0), USER_ONE)
|
||||
);
|
||||
newAccessPoints.push(
|
||||
createNewAccessPointEvent(1, 'secondAP', BigInt.fromI32(1), USER_ONE)
|
||||
);
|
||||
|
||||
// User Two has one access point for tokenId 0
|
||||
newAccessPoints.push(
|
||||
createNewAccessPointEvent(2, 'thirdAP', BigInt.fromI32(0), USER_TWO)
|
||||
);
|
||||
handleNewAccessPoints(newAccessPoints);
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
clearStore();
|
||||
});
|
||||
|
||||
describe('Assertions', () => {
|
||||
test('Check the `nameVerified` field of each access point entity', () => {
|
||||
assert.fieldEquals('AccessPoint', 'firstAP', 'nameVerified', 'false');
|
||||
assert.fieldEquals('AccessPoint', 'secondAP', 'nameVerified', 'false');
|
||||
assert.fieldEquals('AccessPoint', 'thirdAP', 'nameVerified', 'false');
|
||||
});
|
||||
|
||||
test('Check the `nameVerified` field of each access point entity after changing it', () => {
|
||||
// New Access Point Name Verified fields
|
||||
const changeAccessPointNameVerifies: ChangeAccessPointNameVerify[] = [];
|
||||
|
||||
changeAccessPointNameVerifies.push(
|
||||
createNewChangeAccessPointNameVerify(
|
||||
0,
|
||||
'firstAP',
|
||||
BigInt.fromI32(0),
|
||||
true,
|
||||
USER_ONE
|
||||
)
|
||||
);
|
||||
changeAccessPointNameVerifies.push(
|
||||
createNewChangeAccessPointNameVerify(
|
||||
0,
|
||||
'secondAP',
|
||||
BigInt.fromI32(1),
|
||||
true,
|
||||
USER_ONE
|
||||
)
|
||||
);
|
||||
|
||||
changeAccessPointNameVerifies.push(
|
||||
createNewChangeAccessPointNameVerify(
|
||||
0,
|
||||
'thirdAP',
|
||||
BigInt.fromI32(0),
|
||||
true,
|
||||
USER_TWO
|
||||
)
|
||||
);
|
||||
|
||||
handleChangeAccessPointNameVerifies(changeAccessPointNameVerifies);
|
||||
|
||||
assert.fieldEquals('AccessPoint', 'firstAP', 'nameVerified', 'true');
|
||||
assert.fieldEquals('AccessPoint', 'secondAP', 'nameVerified', 'true');
|
||||
assert.fieldEquals('AccessPoint', 'thirdAP', 'nameVerified', 'true');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,449 +0,0 @@
|
|||
import { newMockEvent } from 'matchstick-as';
|
||||
import { ethereum, Address, BigInt, Bytes } from '@graphprotocol/graph-ts';
|
||||
import {
|
||||
Approval as ApprovalEvent,
|
||||
ApprovalForAll as ApprovalForAllEvent,
|
||||
Transfer as TransferEvent,
|
||||
NewMint as NewMintEvent,
|
||||
NewAccessPoint,
|
||||
ChangeAccessPointCreationStatus,
|
||||
ChangeAccessPointNameVerify,
|
||||
TokenRoleChanged,
|
||||
CollectionRoleChanged,
|
||||
} from '../../../generated/FleekNFA/FleekNFA';
|
||||
import {
|
||||
handleApproval,
|
||||
handleApprovalForAll,
|
||||
handleChangeAccessPointCreationStatus,
|
||||
handleChangeAccessPointNameVerify,
|
||||
handleNewAccessPoint,
|
||||
handleNewMint,
|
||||
handleTransfer,
|
||||
handleTokenRoleChanged,
|
||||
handleCollectionRoleChanged,
|
||||
} from '../../../src/fleek-nfa';
|
||||
|
||||
export function createApprovalEvent(
|
||||
event_count: i32,
|
||||
owner: Address,
|
||||
approved: Address,
|
||||
tokenId: bigint
|
||||
): ApprovalEvent {
|
||||
const approvalEvent = changetype<ApprovalEvent>(newMockEvent());
|
||||
|
||||
approvalEvent.parameters = [];
|
||||
|
||||
approvalEvent.parameters.push(
|
||||
new ethereum.EventParam('owner', ethereum.Value.fromAddress(owner))
|
||||
);
|
||||
approvalEvent.parameters.push(
|
||||
new ethereum.EventParam('approved', ethereum.Value.fromAddress(approved))
|
||||
);
|
||||
approvalEvent.parameters.push(
|
||||
new ethereum.EventParam(
|
||||
'tokenId',
|
||||
ethereum.Value.fromUnsignedBigInt(tokenId)
|
||||
)
|
||||
);
|
||||
|
||||
approvalEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||
approvalEvent.logIndex = new BigInt(event_count);
|
||||
|
||||
return approvalEvent;
|
||||
}
|
||||
|
||||
export function createApprovalForAllEvent(
|
||||
event_count: i32,
|
||||
owner: Address,
|
||||
operator: Address,
|
||||
approved: boolean
|
||||
): ApprovalForAllEvent {
|
||||
const approvalForAllEvent = changetype<ApprovalForAllEvent>(newMockEvent());
|
||||
|
||||
approvalForAllEvent.parameters = [];
|
||||
|
||||
approvalForAllEvent.parameters.push(
|
||||
new ethereum.EventParam('owner', ethereum.Value.fromAddress(owner))
|
||||
);
|
||||
approvalForAllEvent.parameters.push(
|
||||
new ethereum.EventParam('operator', ethereum.Value.fromAddress(operator))
|
||||
);
|
||||
approvalForAllEvent.parameters.push(
|
||||
new ethereum.EventParam('approved', ethereum.Value.fromBoolean(approved))
|
||||
);
|
||||
|
||||
approvalForAllEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||
approvalForAllEvent.logIndex = new BigInt(event_count);
|
||||
|
||||
return approvalForAllEvent;
|
||||
}
|
||||
|
||||
export function createTransferEvent(
|
||||
event_count: i32,
|
||||
from: Address,
|
||||
to: Address,
|
||||
tokenId: bigint
|
||||
): TransferEvent {
|
||||
const transferEvent = changetype<TransferEvent>(newMockEvent());
|
||||
|
||||
transferEvent.parameters = [];
|
||||
|
||||
transferEvent.parameters.push(
|
||||
new ethereum.EventParam('from', ethereum.Value.fromAddress(from))
|
||||
);
|
||||
transferEvent.parameters.push(
|
||||
new ethereum.EventParam('to', ethereum.Value.fromAddress(to))
|
||||
);
|
||||
transferEvent.parameters.push(
|
||||
new ethereum.EventParam(
|
||||
'tokenId',
|
||||
ethereum.Value.fromUnsignedBigInt(tokenId)
|
||||
)
|
||||
);
|
||||
|
||||
transferEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||
transferEvent.logIndex = new BigInt(event_count);
|
||||
|
||||
return transferEvent;
|
||||
}
|
||||
|
||||
export function createNewMintEvent(
|
||||
event_count: i32,
|
||||
to: Address,
|
||||
tokenId: bigint
|
||||
): NewMintEvent {
|
||||
const newMintEvent = changetype<NewMintEvent>(newMockEvent());
|
||||
|
||||
newMintEvent.parameters = [];
|
||||
|
||||
newMintEvent.parameters.push(
|
||||
new ethereum.EventParam(
|
||||
'tokenId',
|
||||
ethereum.Value.fromUnsignedBigInt(tokenId)
|
||||
)
|
||||
);
|
||||
newMintEvent.parameters.push(
|
||||
new ethereum.EventParam('name', ethereum.Value.fromString('name'))
|
||||
);
|
||||
newMintEvent.parameters.push(
|
||||
new ethereum.EventParam(
|
||||
'description',
|
||||
ethereum.Value.fromString('description')
|
||||
)
|
||||
);
|
||||
newMintEvent.parameters.push(
|
||||
new ethereum.EventParam(
|
||||
'externalURL',
|
||||
ethereum.Value.fromString('externalurl')
|
||||
)
|
||||
);
|
||||
newMintEvent.parameters.push(
|
||||
new ethereum.EventParam('ENS', ethereum.Value.fromString('ens'))
|
||||
);
|
||||
newMintEvent.parameters.push(
|
||||
new ethereum.EventParam('commitHash', ethereum.Value.fromString('hash'))
|
||||
);
|
||||
newMintEvent.parameters.push(
|
||||
new ethereum.EventParam('gitRepository', ethereum.Value.fromString('repo'))
|
||||
);
|
||||
newMintEvent.parameters.push(
|
||||
new ethereum.EventParam('logo', ethereum.Value.fromString('logo'))
|
||||
);
|
||||
newMintEvent.parameters.push(
|
||||
new ethereum.EventParam('color', ethereum.Value.fromI32(1234))
|
||||
);
|
||||
newMintEvent.parameters.push(
|
||||
new ethereum.EventParam(
|
||||
'accessPointAutoApproval',
|
||||
ethereum.Value.fromBoolean(true)
|
||||
)
|
||||
);
|
||||
newMintEvent.parameters.push(
|
||||
new ethereum.EventParam('minter', ethereum.Value.fromAddress(to))
|
||||
);
|
||||
newMintEvent.parameters.push(
|
||||
new ethereum.EventParam('owner', ethereum.Value.fromAddress(to))
|
||||
);
|
||||
newMintEvent.parameters.push(
|
||||
new ethereum.EventParam('verifier', ethereum.Value.fromAddress(to))
|
||||
);
|
||||
|
||||
newMintEvent.transaction.hash = Bytes.fromI32(event_count);
|
||||
newMintEvent.logIndex = new BigInt(event_count);
|
||||
|
||||
return newMintEvent;
|
||||
}
|
||||
|
||||
export function createNewAccessPointEvent(
|
||||
event_count: i32,
|
||||
apName: string,
|
||||
tokenId: bigint,
|
||||
owner: Address
|
||||
): NewAccessPoint {
|
||||
const newAccessPoint = changetype<NewAccessPoint>(newMockEvent());
|
||||
|
||||
newAccessPoint.parameters = [];
|
||||
|
||||
newAccessPoint.parameters.push(
|
||||
new ethereum.EventParam(
|
||||
'apName',
|
||||
ethereum.Value.fromString(apName.toString())
|
||||
)
|
||||
);
|
||||
|
||||
newAccessPoint.parameters.push(
|
||||
new ethereum.EventParam(
|
||||
'tokenId',
|
||||
ethereum.Value.fromUnsignedBigInt(tokenId)
|
||||
)
|
||||
);
|
||||
|
||||
newAccessPoint.parameters.push(
|
||||
new ethereum.EventParam('owner', ethereum.Value.fromAddress(owner))
|
||||
);
|
||||
|
||||
newAccessPoint.transaction.hash = Bytes.fromI32(event_count);
|
||||
newAccessPoint.logIndex = new BigInt(event_count);
|
||||
|
||||
return newAccessPoint;
|
||||
}
|
||||
|
||||
export function createNewChangeAccessPointCreationStatus(
|
||||
event_count: i32,
|
||||
apName: string,
|
||||
tokenId: bigint,
|
||||
status: i32,
|
||||
triggeredBy: Address
|
||||
): ChangeAccessPointCreationStatus {
|
||||
const changeAccessPointCreationStatus =
|
||||
changetype<ChangeAccessPointCreationStatus>(newMockEvent());
|
||||
|
||||
changeAccessPointCreationStatus.parameters = [];
|
||||
|
||||
changeAccessPointCreationStatus.parameters.push(
|
||||
new ethereum.EventParam(
|
||||
'apName',
|
||||
ethereum.Value.fromString(apName.toString())
|
||||
)
|
||||
);
|
||||
|
||||
changeAccessPointCreationStatus.parameters.push(
|
||||
new ethereum.EventParam(
|
||||
'tokenId',
|
||||
ethereum.Value.fromUnsignedBigInt(tokenId)
|
||||
)
|
||||
);
|
||||
|
||||
changeAccessPointCreationStatus.parameters.push(
|
||||
new ethereum.EventParam('creationStatus', ethereum.Value.fromI32(status))
|
||||
);
|
||||
|
||||
changeAccessPointCreationStatus.parameters.push(
|
||||
new ethereum.EventParam(
|
||||
'triggeredBy',
|
||||
ethereum.Value.fromAddress(triggeredBy)
|
||||
)
|
||||
);
|
||||
|
||||
changeAccessPointCreationStatus.transaction.hash = Bytes.fromI32(event_count);
|
||||
changeAccessPointCreationStatus.logIndex = new BigInt(event_count);
|
||||
|
||||
return changeAccessPointCreationStatus;
|
||||
}
|
||||
|
||||
export function createNewChangeAccessPointNameVerify(
|
||||
event_count: i32,
|
||||
apName: string,
|
||||
tokenId: bigint,
|
||||
verified: boolean,
|
||||
triggeredBy: Address
|
||||
): ChangeAccessPointNameVerify {
|
||||
const changeAccessPointNameVerify = changetype<ChangeAccessPointNameVerify>(
|
||||
newMockEvent()
|
||||
);
|
||||
|
||||
changeAccessPointNameVerify.parameters = [];
|
||||
|
||||
changeAccessPointNameVerify.parameters.push(
|
||||
new ethereum.EventParam(
|
||||
'apName',
|
||||
ethereum.Value.fromString(apName.toString())
|
||||
)
|
||||
);
|
||||
|
||||
changeAccessPointNameVerify.parameters.push(
|
||||
new ethereum.EventParam(
|
||||
'tokenId',
|
||||
ethereum.Value.fromUnsignedBigInt(tokenId)
|
||||
)
|
||||
);
|
||||
|
||||
changeAccessPointNameVerify.parameters.push(
|
||||
new ethereum.EventParam('verified', ethereum.Value.fromBoolean(verified))
|
||||
);
|
||||
|
||||
changeAccessPointNameVerify.parameters.push(
|
||||
new ethereum.EventParam(
|
||||
'triggeredBy',
|
||||
ethereum.Value.fromAddress(triggeredBy)
|
||||
)
|
||||
);
|
||||
|
||||
changeAccessPointNameVerify.transaction.hash = Bytes.fromI32(event_count);
|
||||
changeAccessPointNameVerify.logIndex = new BigInt(event_count);
|
||||
|
||||
return changeAccessPointNameVerify;
|
||||
}
|
||||
|
||||
export function createNewTokenRoleChanged(
|
||||
event_count: i32,
|
||||
tokenId: bigint,
|
||||
role: i32,
|
||||
toAddress: Address,
|
||||
status: boolean,
|
||||
byAddress: Address
|
||||
): TokenRoleChanged {
|
||||
const tokenRoleChanged = changetype<TokenRoleChanged>(newMockEvent());
|
||||
|
||||
tokenRoleChanged.parameters = [];
|
||||
|
||||
tokenRoleChanged.parameters.push(
|
||||
new ethereum.EventParam(
|
||||
'tokenId',
|
||||
ethereum.Value.fromUnsignedBigInt(tokenId)
|
||||
)
|
||||
);
|
||||
|
||||
tokenRoleChanged.parameters.push(
|
||||
new ethereum.EventParam('role', ethereum.Value.fromI32(role))
|
||||
);
|
||||
|
||||
tokenRoleChanged.parameters.push(
|
||||
new ethereum.EventParam('toAddress', ethereum.Value.fromAddress(toAddress))
|
||||
);
|
||||
|
||||
tokenRoleChanged.parameters.push(
|
||||
new ethereum.EventParam('status', ethereum.Value.fromBoolean(status))
|
||||
);
|
||||
|
||||
tokenRoleChanged.parameters.push(
|
||||
new ethereum.EventParam('byAddress', ethereum.Value.fromAddress(byAddress))
|
||||
);
|
||||
|
||||
tokenRoleChanged.transaction.hash = Bytes.fromI32(event_count);
|
||||
tokenRoleChanged.logIndex = new BigInt(event_count);
|
||||
|
||||
return tokenRoleChanged;
|
||||
}
|
||||
|
||||
export function createNewCollectionRoleChanged(
|
||||
event_count: i32,
|
||||
role: i32,
|
||||
toAddress: Address,
|
||||
status: boolean,
|
||||
byAddress: Address
|
||||
): CollectionRoleChanged {
|
||||
const collectionRoleChanged = changetype<CollectionRoleChanged>(
|
||||
newMockEvent()
|
||||
);
|
||||
|
||||
collectionRoleChanged.parameters = [];
|
||||
|
||||
collectionRoleChanged.parameters.push(
|
||||
new ethereum.EventParam('role', ethereum.Value.fromI32(role))
|
||||
);
|
||||
|
||||
collectionRoleChanged.parameters.push(
|
||||
new ethereum.EventParam('toAddress', ethereum.Value.fromAddress(toAddress))
|
||||
);
|
||||
|
||||
collectionRoleChanged.parameters.push(
|
||||
new ethereum.EventParam('status', ethereum.Value.fromBoolean(status))
|
||||
);
|
||||
|
||||
collectionRoleChanged.parameters.push(
|
||||
new ethereum.EventParam('byAddress', ethereum.Value.fromAddress(byAddress))
|
||||
);
|
||||
|
||||
collectionRoleChanged.transaction.hash = Bytes.fromI32(event_count);
|
||||
collectionRoleChanged.logIndex = new BigInt(event_count);
|
||||
|
||||
return collectionRoleChanged;
|
||||
}
|
||||
|
||||
export const CONTRACT: Address = Address.fromString(
|
||||
'0x0000000000000000000000000000000000000000'
|
||||
);
|
||||
export const CONTRACT_OWNER: Address = Address.fromString(
|
||||
'0x1000000000000000000000000000000000000001'
|
||||
);
|
||||
export const USER_ONE: Address = Address.fromString(
|
||||
'0x2000000000000000000000000000000000000002'
|
||||
);
|
||||
export const USER_TWO: Address = Address.fromString(
|
||||
'0x3000000000000000000000000000000000000003'
|
||||
);
|
||||
|
||||
export function handleTransfers(events: TransferEvent[]): void {
|
||||
events.forEach((event) => {
|
||||
handleTransfer(event);
|
||||
});
|
||||
}
|
||||
|
||||
export function handleApprovals(events: ApprovalEvent[]): void {
|
||||
events.forEach((event) => {
|
||||
handleApproval(event);
|
||||
});
|
||||
}
|
||||
|
||||
export function handleNewMints(events: NewMintEvent[]): void {
|
||||
events.forEach((event) => {
|
||||
handleNewMint(event);
|
||||
});
|
||||
}
|
||||
|
||||
export function handleApprovalForAlls(events: ApprovalForAllEvent[]): void {
|
||||
events.forEach((event) => {
|
||||
handleApprovalForAll(event);
|
||||
});
|
||||
}
|
||||
|
||||
export function handleNewAccessPoints(events: NewAccessPoint[]): void {
|
||||
events.forEach((event) => {
|
||||
handleNewAccessPoint(event);
|
||||
});
|
||||
}
|
||||
|
||||
export function handleChangeAccessPointCreationStatusList(
|
||||
events: ChangeAccessPointCreationStatus[]
|
||||
): void {
|
||||
events.forEach((event) => {
|
||||
handleChangeAccessPointCreationStatus(event);
|
||||
});
|
||||
}
|
||||
|
||||
export function handleChangeAccessPointNameVerifies(
|
||||
events: ChangeAccessPointNameVerify[]
|
||||
): void {
|
||||
events.forEach((event) => {
|
||||
handleChangeAccessPointNameVerify(event);
|
||||
});
|
||||
}
|
||||
|
||||
export function handleTokenRoleChangedList(events: TokenRoleChanged[]): void {
|
||||
events.forEach((event) => {
|
||||
handleTokenRoleChanged(event);
|
||||
});
|
||||
}
|
||||
|
||||
export function handleCollectionRoleChangedList(
|
||||
events: CollectionRoleChanged[]
|
||||
): void {
|
||||
events.forEach((event) => {
|
||||
handleCollectionRoleChanged(event);
|
||||
});
|
||||
}
|
||||
|
||||
export function makeEventId(id: i32): string {
|
||||
return Bytes.fromI32(id).toHexString() + '00000000';
|
||||
}
|
||||
|
|
@ -1,132 +0,0 @@
|
|||
import {
|
||||
assert,
|
||||
describe,
|
||||
test,
|
||||
clearStore,
|
||||
beforeAll,
|
||||
afterAll,
|
||||
} from 'matchstick-as/assembly/index';
|
||||
import { BigInt } from '@graphprotocol/graph-ts';
|
||||
import {
|
||||
CONTRACT,
|
||||
createNewMintEvent,
|
||||
createTransferEvent,
|
||||
handleNewMints,
|
||||
handleTransfers,
|
||||
makeEventId,
|
||||
USER_ONE,
|
||||
USER_TWO,
|
||||
} from './helpers/utils';
|
||||
import { NewMint, Transfer } from '../../generated/FleekNFA/FleekNFA';
|
||||
|
||||
describe('Owner tests', () => {
|
||||
beforeAll(() => {
|
||||
// NEW MINTS
|
||||
const newMints: NewMint[] = [];
|
||||
newMints.push(createNewMintEvent(0, USER_ONE, BigInt.fromI32(0)));
|
||||
newMints.push(createNewMintEvent(1, USER_TWO, BigInt.fromI32(1)));
|
||||
newMints.push(createNewMintEvent(2, USER_ONE, BigInt.fromI32(2)));
|
||||
newMints.push(createNewMintEvent(3, USER_ONE, BigInt.fromI32(3)));
|
||||
newMints.push(createNewMintEvent(4, USER_TWO, BigInt.fromI32(4)));
|
||||
handleNewMints(newMints);
|
||||
// TRANSFERS
|
||||
const transfers: Transfer[] = [];
|
||||
transfers.push(
|
||||
createTransferEvent(0, CONTRACT, USER_ONE, BigInt.fromI32(0))
|
||||
);
|
||||
transfers.push(
|
||||
createTransferEvent(1, CONTRACT, USER_TWO, BigInt.fromI32(1))
|
||||
);
|
||||
transfers.push(
|
||||
createTransferEvent(2, CONTRACT, USER_ONE, BigInt.fromI32(2))
|
||||
);
|
||||
transfers.push(
|
||||
createTransferEvent(3, CONTRACT, USER_ONE, BigInt.fromI32(3))
|
||||
);
|
||||
transfers.push(
|
||||
createTransferEvent(4, USER_TWO, USER_ONE, BigInt.fromI32(1))
|
||||
);
|
||||
transfers.push(
|
||||
createTransferEvent(5, CONTRACT, USER_TWO, BigInt.fromI32(4))
|
||||
);
|
||||
transfers.push(
|
||||
createTransferEvent(6, USER_ONE, USER_TWO, BigInt.fromI32(0))
|
||||
);
|
||||
handleTransfers(transfers);
|
||||
//logStore();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
clearStore();
|
||||
});
|
||||
|
||||
describe('Transfers', () => {
|
||||
test('Check the number of transfers to be valid', () => {
|
||||
assert.entityCount('Transfer', 7);
|
||||
});
|
||||
test('Check the `from` and `to` fields of each transfer to be equal to expected values', () => {
|
||||
assert.fieldEquals(
|
||||
'Transfer',
|
||||
makeEventId(0),
|
||||
'to',
|
||||
'0x2000000000000000000000000000000000000002'
|
||||
);
|
||||
assert.fieldEquals(
|
||||
'Transfer',
|
||||
makeEventId(1),
|
||||
'to',
|
||||
'0x3000000000000000000000000000000000000003'
|
||||
);
|
||||
assert.fieldEquals(
|
||||
'Transfer',
|
||||
makeEventId(2),
|
||||
'to',
|
||||
'0x2000000000000000000000000000000000000002'
|
||||
);
|
||||
assert.fieldEquals(
|
||||
'Transfer',
|
||||
makeEventId(3),
|
||||
'to',
|
||||
'0x2000000000000000000000000000000000000002'
|
||||
);
|
||||
assert.fieldEquals(
|
||||
'Transfer',
|
||||
makeEventId(4),
|
||||
'to',
|
||||
'0x2000000000000000000000000000000000000002'
|
||||
);
|
||||
assert.fieldEquals(
|
||||
'Transfer',
|
||||
makeEventId(5),
|
||||
'to',
|
||||
'0x3000000000000000000000000000000000000003'
|
||||
);
|
||||
assert.fieldEquals(
|
||||
'Transfer',
|
||||
makeEventId(6),
|
||||
'to',
|
||||
'0x3000000000000000000000000000000000000003'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Owner Assertions', () => {
|
||||
test('Check the number of owners to be valid', () => {
|
||||
assert.entityCount('Owner', 2);
|
||||
});
|
||||
test('Check the existence of owners in store', () => {
|
||||
assert.fieldEquals(
|
||||
'Owner',
|
||||
USER_ONE.toHexString(),
|
||||
'id',
|
||||
USER_ONE.toHexString()
|
||||
);
|
||||
assert.fieldEquals(
|
||||
'Owner',
|
||||
USER_TWO.toHexString(),
|
||||
'id',
|
||||
USER_TWO.toHexString()
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
import {
|
||||
assert,
|
||||
describe,
|
||||
test,
|
||||
clearStore,
|
||||
beforeAll,
|
||||
afterAll,
|
||||
} from 'matchstick-as/assembly/index';
|
||||
import { BigInt } from '@graphprotocol/graph-ts';
|
||||
import {
|
||||
CONTRACT,
|
||||
createTransferEvent,
|
||||
handleTransfers,
|
||||
makeEventId,
|
||||
USER_ONE,
|
||||
USER_TWO,
|
||||
} from './helpers/utils';
|
||||
import { Transfer } from '../../generated/FleekNFA/FleekNFA';
|
||||
|
||||
describe('Transfer tests', () => {
|
||||
beforeAll(() => {
|
||||
// TRANSFERS
|
||||
const transfers: Transfer[] = [];
|
||||
transfers.push(
|
||||
createTransferEvent(0, CONTRACT, USER_ONE, BigInt.fromI32(0))
|
||||
);
|
||||
transfers.push(
|
||||
createTransferEvent(1, CONTRACT, USER_TWO, BigInt.fromI32(1))
|
||||
);
|
||||
transfers.push(
|
||||
createTransferEvent(2, CONTRACT, USER_ONE, BigInt.fromI32(2))
|
||||
);
|
||||
transfers.push(
|
||||
createTransferEvent(3, CONTRACT, USER_ONE, BigInt.fromI32(3))
|
||||
);
|
||||
transfers.push(
|
||||
createTransferEvent(4, USER_TWO, USER_ONE, BigInt.fromI32(1))
|
||||
);
|
||||
transfers.push(
|
||||
createTransferEvent(5, CONTRACT, USER_TWO, BigInt.fromI32(4))
|
||||
);
|
||||
transfers.push(
|
||||
createTransferEvent(6, USER_ONE, USER_TWO, BigInt.fromI32(0))
|
||||
);
|
||||
handleTransfers(transfers);
|
||||
// logStore();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
clearStore();
|
||||
});
|
||||
|
||||
describe('Transfers', () => {
|
||||
test('Check the number of transfers to be valid', () => {
|
||||
assert.entityCount('Transfer', 7);
|
||||
});
|
||||
test('Check the `from` and `to` fields of each transfer to be equal to expected values', () => {
|
||||
assert.fieldEquals(
|
||||
'Transfer',
|
||||
makeEventId(0),
|
||||
'to',
|
||||
'0x2000000000000000000000000000000000000002'
|
||||
);
|
||||
assert.fieldEquals(
|
||||
'Transfer',
|
||||
makeEventId(1),
|
||||
'to',
|
||||
'0x3000000000000000000000000000000000000003'
|
||||
);
|
||||
assert.fieldEquals(
|
||||
'Transfer',
|
||||
makeEventId(2),
|
||||
'to',
|
||||
'0x2000000000000000000000000000000000000002'
|
||||
);
|
||||
assert.fieldEquals(
|
||||
'Transfer',
|
||||
makeEventId(3),
|
||||
'to',
|
||||
'0x2000000000000000000000000000000000000002'
|
||||
);
|
||||
assert.fieldEquals(
|
||||
'Transfer',
|
||||
makeEventId(4),
|
||||
'to',
|
||||
'0x2000000000000000000000000000000000000002'
|
||||
);
|
||||
assert.fieldEquals(
|
||||
'Transfer',
|
||||
makeEventId(5),
|
||||
'to',
|
||||
'0x3000000000000000000000000000000000000003'
|
||||
);
|
||||
assert.fieldEquals(
|
||||
'Transfer',
|
||||
makeEventId(6),
|
||||
'to',
|
||||
'0x3000000000000000000000000000000000000003'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue