1
1
import { type Address , type Hex } from 'viem'
2
2
import { beforeAll , describe , expect , it } from 'vitest'
3
3
import {
4
- isLegacyRegistrationWithConfig ,
4
+ isLegacyRegistrationWithConfigParameters ,
5
5
makeLegacyCommitment ,
6
6
makeLegacyCommitmentTuple ,
7
7
makeLegacyRegistrationTuple ,
8
8
type LegacyRegistrationParameters ,
9
+ makeLegacyCommitmentWithConfigTuple ,
10
+ makeLegacyRegistrationWithConfigTuple ,
9
11
} from './legacyRegisterHelpers.js'
10
12
import { EMPTY_ADDRESS } from './consts.js'
11
13
import { randomSecret } from './registerHelpers.js'
@@ -42,10 +44,10 @@ beforeAll(async () => {
42
44
; [ owner , address ] = accounts
43
45
} )
44
46
45
- describe ( 'isLegacyRegistrationWithConfig ' , ( ) => {
47
+ describe ( 'isLegacyRegistrationWithConfigParameters ' , ( ) => {
46
48
it ( 'return false when resolverAddress and address are undefined' , ( ) => {
47
49
expect (
48
- isLegacyRegistrationWithConfig ( {
50
+ isLegacyRegistrationWithConfigParameters ( {
49
51
name,
50
52
owner,
51
53
duration,
@@ -56,7 +58,7 @@ describe('isLegacyRegistrationWithConfig', () => {
56
58
57
59
it ( 'return false when resolverAddress and address are empty addresses' , ( ) => {
58
60
expect (
59
- isLegacyRegistrationWithConfig ( {
61
+ isLegacyRegistrationWithConfigParameters ( {
60
62
name,
61
63
owner,
62
64
duration,
@@ -69,7 +71,7 @@ describe('isLegacyRegistrationWithConfig', () => {
69
71
70
72
it ( 'return true when resolverAddress and address are defined' , ( ) => {
71
73
expect (
72
- isLegacyRegistrationWithConfig ( {
74
+ isLegacyRegistrationWithConfigParameters ( {
73
75
name,
74
76
owner,
75
77
duration,
@@ -82,7 +84,7 @@ describe('isLegacyRegistrationWithConfig', () => {
82
84
83
85
it ( 'return true when resolverAddress is defined and address is NOT defined' , ( ) => {
84
86
expect (
85
- isLegacyRegistrationWithConfig ( {
87
+ isLegacyRegistrationWithConfigParameters ( {
86
88
name,
87
89
owner,
88
90
duration,
@@ -94,7 +96,7 @@ describe('isLegacyRegistrationWithConfig', () => {
94
96
95
97
it ( 'should throw an error when address is defined and resolverAddress is NOT defined' , ( ) => {
96
98
expect ( ( ) =>
97
- isLegacyRegistrationWithConfig ( {
99
+ isLegacyRegistrationWithConfigParameters ( {
98
100
name,
99
101
owner,
100
102
duration,
@@ -106,7 +108,7 @@ describe('isLegacyRegistrationWithConfig', () => {
106
108
107
109
it ( 'should throw an error when address is defined and resolverAddress is empty address' , ( ) => {
108
110
expect ( ( ) =>
109
- isLegacyRegistrationWithConfig ( {
111
+ isLegacyRegistrationWithConfigParameters ( {
110
112
name,
111
113
owner,
112
114
duration,
@@ -128,9 +130,11 @@ describe('makeLegacyCommitmentTuple', () => {
128
130
} )
129
131
expect ( tuple ) . toEqual ( [ 'test' , owner , secret ] )
130
132
} )
133
+ } )
131
134
135
+ describe ( 'makeLegacyCommitmentWithConfigTuple' , ( ) => {
132
136
it ( 'should return args for makeCommitWithConfig if resolverAddress is defined' , ( ) => {
133
- const tuple = makeLegacyCommitmentTuple ( {
137
+ const tuple = makeLegacyCommitmentWithConfigTuple ( {
134
138
name : 'test.eth' ,
135
139
owner,
136
140
duration,
@@ -145,18 +149,6 @@ describe('makeLegacyCommitmentTuple', () => {
145
149
EMPTY_ADDRESS ,
146
150
] )
147
151
} )
148
-
149
- it ( 'should throw error if resolverAddress is NOT defined and address is defined' , ( ) => {
150
- expect ( ( ) =>
151
- makeLegacyCommitmentTuple ( {
152
- name : 'test.eth' ,
153
- owner,
154
- duration,
155
- secret,
156
- address,
157
- } ) ,
158
- ) . toThrowErrorMatchingInlineSnapshot ( makeSnapshot ( address ) )
159
- } )
160
152
} )
161
153
162
154
describe ( 'makeLegacyRegistrationTuple' , ( ) => {
@@ -174,34 +166,19 @@ describe('makeLegacyRegistrationTuple', () => {
174
166
secret ,
175
167
] )
176
168
} )
169
+ } )
177
170
178
- it ( 'should return args for register if resolverAddress and address are empty addresses' , ( ) => {
179
- const params : LegacyRegistrationParameters = {
180
- name,
181
- owner,
182
- duration,
183
- secret,
184
- resolverAddress : EMPTY_ADDRESS ,
185
- address : EMPTY_ADDRESS ,
186
- }
187
- expect ( makeLegacyRegistrationTuple ( params ) ) . toEqual ( [
188
- 'test' ,
189
- owner ,
190
- 31536000n ,
191
- secret ,
192
- ] )
193
- } )
194
-
195
- it ( 'should return args for register if resolverAddress and address are not undefined' , ( ) => {
196
- const params : LegacyRegistrationParameters = {
171
+ describe ( 'makeLegacyRegistrationWithConfigTuple' , ( ) => {
172
+ it ( 'should return args for register if resolverAddress and address are defined' , ( ) => {
173
+ const tuple = makeLegacyRegistrationWithConfigTuple ( {
197
174
name : 'test.eth' ,
198
175
owner,
199
176
duration,
200
177
secret,
201
178
resolverAddress,
202
179
address,
203
- }
204
- expect ( makeLegacyRegistrationTuple ( params ) ) . toEqual ( [
180
+ } )
181
+ expect ( tuple ) . toEqual ( [
205
182
'test' ,
206
183
owner ,
207
184
31536000n ,
@@ -254,7 +231,7 @@ describe('makeLegacyCommitment', () => {
254
231
client : publicClient ,
255
232
contract : 'legacyEthRegistrarController' ,
256
233
} ) ,
257
- args : makeLegacyCommitmentTuple ( params ) ,
234
+ args : makeLegacyCommitmentWithConfigTuple ( params ) ,
258
235
} )
259
236
260
237
expect ( commitment ) . toBe ( commitment2 )
0 commit comments