Skip to content

Commit

Permalink
Add multi record update and delete tests
Browse files Browse the repository at this point in the history
sugh01 committed Dec 7, 2023
1 parent 2ea6a60 commit c539693
Showing 3 changed files with 126 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/ensjs/src/functions/wallet/ownership.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -136,7 +136,7 @@ const commitAndRegisterName = async (params: RegistrationParameters) => {



it.skip('Register - unwrapped 2LD', async () => {
it('Register - unwrapped 2LD', async () => {
const name = 'cool-swag-wrap.eth'
const params: RegistrationParameters = {
name: name,
@@ -200,7 +200,7 @@ it.skip('Register - unwrapped 2LD', async () => {

})

it.skip('Register - wrapped 2LD', async () => {``
it('Register - wrapped 2LD', async () => {``
const name = 'cool-swag-wrap.eth'
const params: RegistrationParameters = {
name: name,
@@ -274,7 +274,7 @@ it.skip('Register - wrapped 2LD', async () => {``
expect(transferMgrTxReceipt.status).toBe('success')
})

it.skip('Register - unwrapped 2LD - unwrapped subname', async () => {``
it('Register - unwrapped 2LD - unwrapped subname', async () => {``
const name = 'cool-swag-wrap.eth'
const subname = 'subname.cool-swag-wrap.eth'
const params: RegistrationParameters = {
12 changes: 6 additions & 6 deletions packages/ensjs/src/functions/wallet/registerName.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -108,7 +108,7 @@ const dummyABI = [
},
]

it.skip('Register - Add Eth Address - Set Primary Name - Get Primary Name - Get Expiry - Renew Name', async () => {
it('Register - Add Eth Address - Set Primary Name - Get Primary Name - Get Expiry - Renew Name', async () => {
const params: RegistrationParameters = {
name: 'coolest-swag.eth',
duration: 31536000,
@@ -208,7 +208,7 @@ it.skip('Register - Add Eth Address - Set Primary Name - Get Primary Name - Get

})

it.skip('Register - Get Expiry - Advance time - Renew Name', async () => {
it('Register - Get Expiry - Advance time - Renew Name', async () => {
const params: RegistrationParameters = {
name: 'coolest-swag.eth',
duration: 31536000,
@@ -376,7 +376,7 @@ it.skip('Register - Get Expiry - Advance time - Renew Name', async () => {

})

it.skip('Register - Set other as primary name', async () => {
it('Register - Set other as primary name', async () => {
const params: RegistrationParameters = {
name: 'other-eth-record-2.eth',
duration: 31536000,
@@ -472,7 +472,7 @@ it.skip('Register - Set other as primary name', async () => {

})

it.skip('Register - Set other manager as primary name', async () => {
it('Register - Set other manager as primary name', async () => {
const params: RegistrationParameters = {
name: 'other-eth-record-2.eth',
duration: 31536000,
@@ -584,7 +584,7 @@ it.skip('Register - Set other manager as primary name', async () => {

})

it.skip('Register - Set Subname', async () => {
it('Register - Set Subname', async () => {
const params: RegistrationParameters = {
name: 'cool-swag-wrap.eth',
duration: 31536000,
@@ -689,7 +689,7 @@ it.skip('Register - Set Subname', async () => {
`)
})

it.skip('Register - unwrap 2LD - wrap Subname', async () => {
it('Register - unwrap 2LD - wrap Subname', async () => {
const name = 'cool-swag-wrap.eth'
const params: RegistrationParameters = {
name: name,
117 changes: 117 additions & 0 deletions packages/ensjs/src/functions/wallet/setRecords.test.ts
Original file line number Diff line number Diff line change
@@ -125,3 +125,120 @@ it('should not wrap with multicall if only setting a single record', async () =>
// 0x8b95dd71 is the function selector for setAddr(bytes32,uint256,bytes)
expect(encodedData.data.startsWith('0x8b95dd71')).toBe(true)
})
it('should return a transaction to the resolver and update successfully', async () => {
const tx = await setRecords(walletClient, {
name: 'test123.eth',
resolverAddress: (await getResolver(publicClient, {
name: 'test123.eth',
}))!,
coins: [
{
coin: 'etcLegacy',
value: '0x42D63ae25990889E35F215bC95884039Ba354115',
},
],
texts: [{ key: 'foo', value: 'bar' }],
abi: await encodeAbi({ encodeAs: 'json', data: dummyABI }),
account: accounts[1],
})
expect(tx).toBeTruthy()
const receipt = await waitForTransaction(tx)
expect(receipt.status).toBe('success')
await testClient.mine({ blocks: 1 })


const utx = await setRecords(walletClient, {
name: 'test123.eth',
resolverAddress: (await getResolver(publicClient, {
name: 'test123.eth',
}))!,
coins: [
{
coin: 'etcLegacy',
value: accounts[1],
},
],
texts: [{ key: 'foo', value: 'bars' }],
abi: await encodeAbi({ encodeAs: 'json', data: [...dummyABI,{stateMutability: 'readonly',}] }),
account: accounts[1],
})
expect(utx).toBeTruthy()
const ureceipt = await waitForTransaction(utx)
expect(ureceipt.status).toBe('success')

const records = await getRecords(publicClient, {
name: 'test123.eth',
records: {
coins: ['etcLegacy'],
texts: ['foo'],
abi: true,
},
})
expect(records.abi!.abi).toStrictEqual([...dummyABI,{stateMutability: 'readonly',}])
expect(records.coins).toMatchInlineSnapshot(`
[
{
"id": 61,
"name": "etcLegacy",
"value": "${accounts[1]}",
},
]
`)
expect(records.texts).toMatchInlineSnapshot(`
[
{
"key": "foo",
"value": "bars",
},
]
`)
})
it.only('should return a transaction to the resolver and remove successfully', async () => {
const tx = await setRecords(walletClient, {
name: 'test123.eth',
resolverAddress: (await getResolver(publicClient, {
name: 'test123.eth',
}))!,
coins: [
{
coin: 'etcLegacy',
value: '0x42D63ae25990889E35F215bC95884039Ba354115',
},
],
texts: [{ key: 'foo', value: 'bar' }],
abi: await encodeAbi({ encodeAs: 'json', data: dummyABI }),
account: accounts[1],
})
expect(tx).toBeTruthy()
const receipt = await waitForTransaction(tx)
expect(receipt.status).toBe('success')
await testClient.mine({ blocks: 1 })


const utx = await setRecords(walletClient, {
name: 'test123.eth',
resolverAddress: (await getResolver(publicClient, {
name: 'test123.eth',
}))!,
coins: [],
texts: [],
abi: null,
account: accounts[1],
})
expect(utx).toBeTruthy()
const ureceipt = await waitForTransaction(utx)
expect(ureceipt.status).toBe('success')

const records = await getRecords(publicClient, {
name: 'test123.eth',
records: {
coins: [],
texts: [],
abi: true,
},
})
expect(records.abi!.abi).toMatchInlineSnapshot(`abi: { contentType: 1, decoded: true, abi: [ [Object] ] }`)
expect(records.coins).toMatchInlineSnapshot(`[]`)
expect(records.texts).toMatchInlineSnapshot(`[]`)
console.log(records)
})

0 comments on commit c539693

Please sign in to comment.