Skip to content

Commit

Permalink
Reinstate RequesterAuthorizerWithErc721 tests
Browse files Browse the repository at this point in the history
Change RequesterAuthorizerWithErc721 related chainIds to 11155111 to
utilize the Sepolia deployment
  • Loading branch information
dcroote committed Dec 14, 2023
1 parent bedf656 commit e5b65c3
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .changeset/orange-dingos-trade.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
'@api3/airnode-node': minor
---

Bump axios and @api3 deps and remove tests and code reliant on deployed RequesterAuthorizerWithErc721 addresses
Bump axios and @api3 deps
21 changes: 19 additions & 2 deletions packages/airnode-node/config/config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,25 @@
}
}
],
"requesterAuthorizersWithErc721": [],
"crossChainRequesterAuthorizersWithErc721": []
"requesterAuthorizersWithErc721": [
{
"erc721s": ["0x00bDB2315678afecb367f032d93F642f64180a00"],
"RequesterAuthorizerWithErc721": "0x8e0b4538f4f6D94D3dF9b30D17E31D4C3Be9dA30"
}
],
"crossChainRequesterAuthorizersWithErc721": [
{
"erc721s": ["0x3FbDB2315678afecb367f032d93F642f64180aa6"],
"chainType": "evm",
"chainId": "11155111",
"contracts": {
"RequesterAuthorizerWithErc721": "0x8e0b4538f4f6D94D3dF9b30D17E31D4C3Be9dA30"
},
"chainProvider": {
"url": "http://127.0.0.2"
}
}
]
},
"authorizations": {
"requesterEndpointAuthorizations": {}
Expand Down
15 changes: 14 additions & 1 deletion packages/airnode-node/src/config/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ import { references } from '@api3/airnode-protocol';
import { loadTrustedConfig } from '../index';

const AirnodeRrpV0Addresses: { [chainId: string]: string } = references.AirnodeRrpV0;
const RequesterAuthorizerWithErc721Addresses: { [chainId: string]: string } = references.RequesterAuthorizerWithErc721;

describe('config validation', () => {
const exampleConfigPath = join(__dirname, '../../config/config.example.json');
const exampleSecrets = dotenv.parse(readFileSync(join(__dirname, '../../config/secrets.example.env')));

it('loads the config and adds default contract addresses', () => {
const chainId = '5';
const chainId = '11155111';
const invalidConfig = JSON.parse(readFileSync(exampleConfigPath, 'utf-8'));
invalidConfig.chains[0].id = chainId; // Need to use an actual chain not hardhat
delete invalidConfig.chains[0].contracts;
delete invalidConfig.chains[0].authorizers.crossChainRequesterAuthorizers[0].contracts;
delete invalidConfig.chains[0].authorizers.crossChainRequesterAuthorizersWithErc721[0].contracts;
delete invalidConfig.chains[0].authorizers.requesterAuthorizersWithErc721[0].RequesterAuthorizerWithErc721;

mockReadFileSync('config.example.json', JSON.stringify(invalidConfig));

Expand All @@ -26,5 +29,15 @@ describe('config validation', () => {
expect(config.chains[0].authorizers.crossChainRequesterAuthorizers[0].contracts.AirnodeRrp).toEqual(
AirnodeRrpV0Addresses[config.chains[0].authorizers.crossChainRequesterAuthorizers[0].chainId]
);
expect(
config.chains[0].authorizers.crossChainRequesterAuthorizersWithErc721[0].contracts.RequesterAuthorizerWithErc721
).toEqual(
RequesterAuthorizerWithErc721Addresses[
config.chains[0].authorizers.crossChainRequesterAuthorizersWithErc721[0].chainId
]
);
expect(config.chains[0].authorizers.requesterAuthorizersWithErc721[0].RequesterAuthorizerWithErc721).toEqual(
RequesterAuthorizerWithErc721Addresses[config.chains[0].id]
);
});
});
2 changes: 1 addition & 1 deletion packages/airnode-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"typescript": "^5.2.2"
},
"dependencies": {
"@api3/airnode-protocol-v1": "^3.0.0",
"@api3/airnode-protocol-v1": "^3.1.0",
"@openzeppelin/contracts": "4.4.2",
"ethers": "^5.7.2"
}
Expand Down
24 changes: 24 additions & 0 deletions packages/airnode-validator/src/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,18 @@ describe('ensureCrossChainRequesterAuthorizerWithErc721', () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { contracts, ...crossChainWithoutAddress } = crossChainRequesterAuthorizerWithErc721;

it('adds the default RequesterAuthorizerWithErc721 contract address for the given chain if the chain has a deployment', () => {
const idWithDeployment = '11155111';
const crossChainWithDeployment = {
...crossChainWithoutAddress,
chainId: idWithDeployment,
};
const parsed = crossChainRequesterAuthorizersWithErc721Schema.parse(crossChainWithDeployment);
expect(parsed.contracts).toEqual({
RequesterAuthorizerWithErc721: RequesterAuthorizerWithErc721Addresses[idWithDeployment],
});
});

it('fails if RequesterAuthorizerWithErc721 contract address is not specified and there is no deployment for the chain', () => {
const idWithoutDeployment = '99999999999999999999999';
const crossChainWithoutDeployment = {
Expand Down Expand Up @@ -904,6 +916,18 @@ describe('ensureRequesterAuthorizerWithErc721', () => {
delete chainWithoutRequesterAuthorizerWithErc721Address.authorizers.requesterAuthorizersWithErc721[0]
.RequesterAuthorizerWithErc721;

it('adds the default RequesterAuthorizerWithErc721 contract address for the given chain if the chain has a deployment', () => {
const idWithDeployment = '11155111';
const configWithDeployment = {
...chainWithoutRequesterAuthorizerWithErc721Address,
id: idWithDeployment,
};
const parsed = chainConfigSchema.parse(configWithDeployment);
expect(parsed.authorizers.requesterAuthorizersWithErc721[0].RequesterAuthorizerWithErc721).toEqual(
RequesterAuthorizerWithErc721Addresses[idWithDeployment]
);
});

it('fails if RequesterAuthorizerWithErc721 contract address is not specified and there is no deployment for the chain', () => {
const idWithoutDeployment = '99999999999999999999999';
const crossChainWithoutDeployment = {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"@jridgewell/gen-mapping" "^0.3.0"
"@jridgewell/trace-mapping" "^0.3.9"

"@api3/airnode-protocol-v1@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@api3/airnode-protocol-v1/-/airnode-protocol-v1-3.0.0.tgz#2d7e07050a4c14f26aececcf42812191bc119d50"
integrity sha512-QMBLPxxnbibxweoRLnPOiGMTPqHnAmqn1BRrSTJS9APcdB2FfDqozcRW1Ye5oHLQL1wOH973hJODetWHcBUf8g==
"@api3/airnode-protocol-v1@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@api3/airnode-protocol-v1/-/airnode-protocol-v1-3.1.0.tgz#b4cfe0a0321f51326e959d7201a8094454fc2cbc"
integrity sha512-3XOYdQqQPWXC2xSz1cCnk6kzkeugE6NdxgU25C43dzkJStvY+jALyxmS9SBtsUCaq4KA7hYVxci5gkDi7rZbAQ==
dependencies:
"@openzeppelin/contracts" "4.8.2"

Expand Down

0 comments on commit e5b65c3

Please sign in to comment.