Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: test cases for registry #14

Merged
merged 24 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
857acc8
init
mohandast52 Mar 15, 2024
5de0a89
move ADDRESSES to typescript
mohandast52 Mar 15, 2024
14a6c7d
Fix eslint, enable git workflow
Tanya-atatakai Mar 15, 2024
402c738
Update git workflow
Tanya-atatakai Mar 17, 2024
81b6bdb
Fix test running
Tanya-atatakai Mar 17, 2024
f027486
tests added for fallback handler
mohandast52 Mar 18, 2024
16a95d2
test-cases for multi_send_call_only
mohandast52 Mar 18, 2024
1c1e2b5
mock dummySvmConnectivity for failing tests
mohandast52 Mar 18, 2024
d2875dd
arrange test folders
mohandast52 Mar 18, 2024
71fa367
Fix git workflow jobs, comment test for registry
Tanya-atatakai Mar 18, 2024
05bd986
Make gitleaks not fail
Tanya-atatakai Mar 18, 2024
1d9a3c2
service details works
mohandast52 Mar 18, 2024
d465d92
details tests
mohandast52 Mar 18, 2024
ef9297c
list agents and list components working
mohandast52 Mar 19, 2024
80ba37c
test-pasees
mohandast52 Mar 19, 2024
7417791
fixes
mohandast52 Mar 19, 2024
c94348e
Merge pull request #13 from valory-xyz/fix/git-workflow
mohandast52 Mar 19, 2024
b0f8ecc
Uncomment test step for registry
Tanya-atatakai Mar 19, 2024
6049417
update yarn.lock
mohandast52 Mar 19, 2024
a9ed542
Merge branch 'mohan/registry-test-cases' of github.com-personal:valor…
mohandast52 Mar 19, 2024
70ad7c2
delete package-lock.json
mohandast52 Mar 19, 2024
98c6a33
Fix gitleaks
Tanya-atatakai Mar 19, 2024
517bb6b
Update gitleaksignores
Tanya-atatakai Mar 19, 2024
e87f009
Merge pull request #15 from valory-xyz/fix/gitleaks-ignore
mohandast52 Mar 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
import { Address } from 'viem';
import {
LOCAL_FORK_ID,
LOCAL_FORK_ID_GNOSIS,
LOCAL_FORK_ID_POLYGON,
} from 'util/constants';
} from '../../util/constants';

const MAINNET_ADDRESSES = {
type Addresses = {
serviceManagerToken: Address;
serviceRegistryL2: Address;
serviceRegistryTokenUtility: Address;
operatorWhitelist: Address;
};

type L1Addresses = {
agentRegistry: Address;
componentRegistry: Address;
registriesManager: Address;
serviceManagerToken: Address;
serviceRegistry: Address;
serviceRegistryTokenUtility: Address;
operatorWhitelist: Address;
};

const MAINNET_ADDRESSES: L1Addresses = {
agentRegistry: '0x2F1f7D38e4772884b88f3eCd8B6b9faCdC319112',
componentRegistry: '0x15bd56669F57192a97dF41A2aa8f4403e9491776',
registriesManager: '0x9eC9156dEF5C613B2a7D4c46C383F9B58DfcD6fE',
Expand All @@ -14,14 +32,14 @@ const MAINNET_ADDRESSES = {
operatorWhitelist: '0x42042799B0DE38AdD2a70dc996f69f98E1a85260',
};

const GNOSIS_ADDRESSES = {
const GNOSIS_ADDRESSES: Addresses = {
serviceManagerToken: '0x04b0007b2aFb398015B76e5f22993a1fddF83644',
serviceRegistryL2: '0x9338b5153AE39BB89f50468E608eD9d764B755fD',
serviceRegistryTokenUtility: '0xa45E64d13A30a51b91ae0eb182e88a40e9b18eD8',
operatorWhitelist: '0x526E064cB694E8f5B7DB299158e17F33055B3943',
};

const POLYGON_ADDRESSES = {
const POLYGON_ADDRESSES: Addresses = {
serviceManagerToken: '0x04b0007b2aFb398015B76e5f22993a1fddF83644',
serviceRegistryL2: '0xE3607b00E75f6405248323A9417ff6b39B244b50',
serviceRegistryTokenUtility: '0xa45E64d13A30a51b91ae0eb182e88a40e9b18eD8',
Expand All @@ -35,7 +53,7 @@ const POLYGON_ADDRESSES = {
* - optimistic
* - celo
*/
const COMMON_TEST_ADDRESSES = {
const COMMON_TEST_ADDRESSES: Addresses = {
serviceManagerToken: '0x5BA58970c2Ae16Cf6218783018100aF2dCcFc915',
serviceRegistryL2: '0x31D3202d8744B16A120117A053459DDFAE93c855',
serviceRegistryTokenUtility: '0xeB49bE5DF00F74bd240DE4535DDe6Bc89CEfb994',
Expand Down Expand Up @@ -110,38 +128,31 @@ export const ADDRESSES = {
11155420: COMMON_TEST_ADDRESSES,
// celo alfajores - testnet for celo
44787: COMMON_TEST_ADDRESSES,
// local
31337: {
agentRegistry: '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
componentRegistry: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
registriesManager: '0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0',
serviceRegistry: '0x998abeb3E57409262aE5b751f60747921B33613E',
serviceManager: '0x4c5859f0F772848b2D91F1D83E2Fe57935348029',
serviceRegistryTokenUtility: '0x36C02dA8a0983159322a80FFE9F24b1acfF8B570',
operatorWhitelist: '0x809d550fca64d94Bd9F66E60752A544199cfAC3D',
// used for testing - service creation/update token address
ERC20Token: '0x1291Be112d480055DaFd8a610b7d1e203891C274',
},
[LOCAL_FORK_ID]: MAINNET_ADDRESSES,
[LOCAL_FORK_ID_GNOSIS]: GNOSIS_ADDRESSES,
[LOCAL_FORK_ID_POLYGON]: POLYGON_ADDRESSES,
};
} as const;

export type ChainIds = keyof typeof ADDRESSES;

type MultisigAddress = {
[chainId in ChainIds]: Address[];
};
// TODO: add testcases for all networks
/**
* check addresses here - GnosisSafeMultisig
* Addresses: https://github.com/valory-xyz/autonolas-registries/blob/main/docs/configuration.json
*/
export const multisigAddresses = {
export const multisigAddresses: MultisigAddress = {
1: ['0x46C0D07F55d4F9B5Eed2Fc9680B5953e5fd7b461'],
5: ['0x65dD51b02049ad1B6FF7fa9Ea3322E1D2CAb1176'],
10: ['0xE43d4F4103b623B61E095E8bEA34e1bc8979e168'],
100: ['0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE'],
137: ['0x3d77596beb0f130a4415df3D2D8232B3d3D31e44'],
8453: ['0xBb7e1D6Cb6F243D6bdE81CE92a9f2aFF7Fbe7eac'],
10200: ['0xeB49bE5DF00F74bd240DE4535DDe6Bc89CEfb994'],
80001: ['0x9dEc6B62c197268242A768dc3b153AE7a2701396'],
84532: ['0x19936159B528C66750992C3cBcEd2e71cF4E4824'],
31337: ['0x0E801D84Fa97b50751Dbf25036d067dCf18858bF'],
42161: ['0x63e66d7ad413C01A7b49C7FF4e3Bb765C4E4bd1b'],
42220: ['0x63e66d7ad413C01A7b49C7FF4e3Bb765C4E4bd1b'],
421614: ['0x19936159B528C66750992C3cBcEd2e71cF4E4824'],
Expand All @@ -152,21 +163,20 @@ export const multisigAddresses = {
[LOCAL_FORK_ID_POLYGON]: ['0x3d77596beb0f130a4415df3D2D8232B3d3D31e44'],
};

// TODO: add testcases for all networks
/**
* check addresses here - GnosisSafeSameAddressMultisig
* Addresses: https://github.com/valory-xyz/autonolas-registries/blob/main/docs/configuration.json
*/
export const multisigSameAddresses = {
export const multisigSameAddresses: MultisigAddress = {
1: ['0xfa517d01DaA100cB1932FA4345F68874f7E7eF46'],
5: ['0x06467Cb835da623384a22aa902647784C1c9f5Ae'],
10: ['0xb09CcF0Dbf0C178806Aaee28956c74bd66d21f73'],
100: ['0x6e7f594f680f7aBad18b7a63de50F0FeE47dfD06'],
137: ['0xd8BCC126ff31d2582018715d5291A508530587b0'],
10200: ['0xE16adc7777B7C2a0d35033bd3504C028AB28EE8b'],
8453: ['0xFbBEc0C8b13B38a9aC0499694A69a10204c5E2aB'],
80001: ['0xd6AA4Ec948d84f6Db8EEf25104CeE0Ecd280C74e'],
84532: ['0x10100e74b7F706222F8A7C0be9FC7Ae1717Ad8B2'],
31337: ['0x8f86403A4DE0BB5791fa46B8e795C547942fE4Cf'],
42161: ['0xBb7e1D6Cb6F243D6bdE81CE92a9f2aFF7Fbe7eac'],
42220: ['0xBb7e1D6Cb6F243D6bdE81CE92a9f2aFF7Fbe7eac'],
421614: ['0x10100e74b7F706222F8A7C0be9FC7Ae1717Ad8B2'],
Expand All @@ -177,21 +187,20 @@ export const multisigSameAddresses = {
[LOCAL_FORK_ID_POLYGON]: ['0xd8BCC126ff31d2582018715d5291A508530587b0'],
};

// TODO: add testcases for all networks
/**
* check addresses here - MultiSendCallOnly
* https://github.com/safe-global/safe-deployments/blob/main/src/assets/v1.3.0/multi_send_call_only.json
*/
export const safeMultiSend = {
export const safeMultiSend: MultisigAddress = {
1: ['0x40A2aCCbd92BCA938b02010E17A5b8929b49130D'],
5: ['0x40A2aCCbd92BCA938b02010E17A5b8929b49130D'],
10: ['0xA1dabEF33b3B82c7814B6D82A79e50F4AC44102B'],
100: ['0x40A2aCCbd92BCA938b02010E17A5b8929b49130D'],
137: ['0x40A2aCCbd92BCA938b02010E17A5b8929b49130D'],
8453: ['0xA1dabEF33b3B82c7814B6D82A79e50F4AC44102B'],
10200: ['0x40A2aCCbd92BCA938b02010E17A5b8929b49130D'],
80001: ['0x40A2aCCbd92BCA938b02010E17A5b8929b49130D'],
84532: ['0xA1dabEF33b3B82c7814B6D82A79e50F4AC44102B'],
31337: ['0x9d4454B023096f34B160D6B654540c56A1F81688'],
42161: ['0x40A2aCCbd92BCA938b02010E17A5b8929b49130D'],
42220: ['0xA1dabEF33b3B82c7814B6D82A79e50F4AC44102B'],
421614: ['0x40A2aCCbd92BCA938b02010E17A5b8929b49130D'],
Expand All @@ -202,21 +211,22 @@ export const safeMultiSend = {
[LOCAL_FORK_ID_POLYGON]: ['0x40A2aCCbd92BCA938b02010E17A5b8929b49130D'],
};

// TODO: add testcases for all networks
/**
* check addresses here
* https://github.com/safe-global/safe-deployments/blob/main/src/assets/v1.3.0/compatibility_fallback_handler.json
*/
export const FALLBACK_HANDLER = {
export const FALLBACK_HANDLER: {
[chainId in ChainIds]: Address;
} = {
1: '0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4',
5: '0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4',
10: '0x017062a1dE2FE6b99BE3d9d37841FeD19F573804',
100: '0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4',
137: '0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4',
8453: '0x017062a1dE2FE6b99BE3d9d37841FeD19F573804',
10200: '0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4',
80001: '0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4',
84532: '0x017062a1dE2FE6b99BE3d9d37841FeD19F573804',
31337: '0x0000000000000000000000000000000000000000',
mohandast52 marked this conversation as resolved.
Show resolved Hide resolved
42161: '0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4',
42220: '0x017062a1dE2FE6b99BE3d9d37841FeD19F573804',
421614: '0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4',
Expand Down
2 changes: 1 addition & 1 deletion apps/autonolas-registry/common-util/Details/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Header, DetailsTitle } from './styles';

const { Text } = Typography;

const Details = ({
export const Details = ({
id,
type,
getDetails,
Expand Down
1 change: 1 addition & 0 deletions apps/autonolas-registry/common-util/hooks/index.jsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { useHelpers } from './useHelpers';
export { useScreen } from './useScreen';
export { useSvmConnectivity } from './useSvmConnectivity';
4 changes: 2 additions & 2 deletions apps/autonolas-registry/components/GlobalStyles/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const GlobalStyle = createGlobalStyle`
}
html {
/* uncomment for dark mode */
/* background-color: ${COLOR.WHITE}; */
/* filter: invert(0.85) hue-rotate(180deg); */
background-color: ${COLOR.WHITE};
filter: invert(0.85) hue-rotate(180deg);
}

/* common */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ const { Text } = Typography;
const STEP = 2;

const getIdsAndAgentInstances = (dataSource) => {
const trimArray = (string) => (string || [])
.join()
.split(',')
.map((e) => e.trim());
const trimArray = (string) =>
(string || [])
.join()
.split(',')
.map((e) => e.trim());

const ids = [];

Expand Down Expand Up @@ -65,9 +66,8 @@ export const ActiveRegistration = ({
isEthToken,
updateDetails,
}) => {
const {
isSvm, account, chainId, doesNetworkHaveValidServiceManagerToken,
} = useHelpers();
const { isSvm, account, chainId, doesNetworkHaveValidServiceManagerToken } =
useHelpers();
const { getSvmBonds } = useSvmBonds();

const [totalBonds, setTotalBond] = useState(null);
Expand All @@ -85,9 +85,11 @@ export const ActiveRegistration = ({
(async () => {
if (serviceId) {
try {
const { totalBonds: totalBondsRes } = isSvm
const bondsInfo = isSvm
? await getSvmBonds(serviceId, dataSource)
: await getBonds(serviceId, dataSource);
const totalBondsRes = bondsInfo?.totalBonds;

if (isMounted) {
setTotalBond(totalBondsRes);
}
Expand All @@ -98,10 +100,10 @@ export const ActiveRegistration = ({
}

if (
serviceId
&& !isEthToken
&& doesNetworkHaveValidServiceManagerToken
&& !isSvm
serviceId &&
!isEthToken &&
doesNetworkHaveValidServiceManagerToken &&
!isSvm
) {
const response = await getTokenBondRequest(serviceId, dataSource);
setEthTokenBonds(response);
Expand Down Expand Up @@ -163,7 +165,7 @@ export const ActiveRegistration = ({
const totalBondEthToken = convertToEth((totalBonds || 0).toString()) || '--';

let totalTokenBonds = 0;
ethTokenBonds.forEach((bond, index) => {
ethTokenBonds?.forEach((bond, index) => {
const addressCount = getNumberOfAgentAddress(
dataSource[index].agentAddresses,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const Deployed = ({
);

return (
<div className="step-4-terminate">
<div className="step-4-deployed" data-testid="step-deployed">
<Space direction="vertical" size={10}>
{isShowAgentInstanceVisible && (
<Table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const ServiceStateContainer = styled.div`
}
}
}
.step-4-terminate {
.step-4-deployed {
> div {
font-size: 16px;
}
Expand Down Expand Up @@ -73,7 +73,7 @@ export const ServiceStateContainer = styled.div`
.ant-radio-group {
display: block;
}
.step-4-terminate {
.step-4-deployed {
.ant-table-wrapper {
width: 300px;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback } from 'react';
import { useRouter } from 'next/router';

import Details from 'common-util/Details';
import { Details } from '../../common-util/Details';
import { useHelpers } from 'common-util/hooks';

import { ServiceState } from './ServiceState';
Expand Down
7 changes: 3 additions & 4 deletions apps/autonolas-registry/components/ListServices/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ const ListServices = () => {
isMyTab(hash) ? MY_SERVICES : ALL_SERVICES,
);

const {
account, chainName, links, isSvm,
} = useHelpers();
const { account, chainName, links, isSvm } = useHelpers();

/**
* extra tab content & view click
Expand Down Expand Up @@ -198,7 +196,8 @@ const ListServices = () => {
setCurrentPage,
onViewClick,
searchValue,
onUpdateClick: (serviceId) => router.push(`${links.UPDATE_SERVICE}/${serviceId}`),
onUpdateClick: (serviceId) =>
router.push(`${links.UPDATE_SERVICE}/${serviceId}`),
};

const myServiceList = searchValue
Expand Down
29 changes: 0 additions & 29 deletions apps/autonolas-registry/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,3 @@ jest.mock('./common-util/Login/config', () => ({
EVM_SUPPORTED_CHAINS: [{ id: 1 }],
SVM_SUPPORTED_CHAINS: [{ id: 1 }],
}));

jest.mock('./common-util/hooks', () => ({
useHelpers: () => ({
account: '0x123',
vmType: 'EVM',
chainId: 1,
chainDisplayName: 'Ethereum',
chainName: 'ethereum',
isL1OnlyNetwork: true,
isL1Network: true,
doesNetworkHaveValidServiceManagerToken: true,
links: { AGENTS: '/ethereum/agents' },
isConnectedToWrongNetwork: false,
isSvm: false,
}),
useSvmConnectivity: () => ({
walletPublicKey: '0x123',
connection: 'connection',
program: 'program',
solanaAddresses: 'solanaAddresses',
hasNoSvmPublicKey: false,
}),
}));

jest.mock('./common-util/hooks/useHelpers', () => ({
useHelpers: () => ({
getAgent: jest.fn(),
}),
}));
10 changes: 0 additions & 10 deletions apps/autonolas-registry/specs/index.spec.tsx

This file was deleted.

Loading