1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { expect } from '../setup'
import { applyL1ToL2Alias, undoL1ToL2Alias } from '../../src'
describe('address aliasing utils', () => {
describe('applyL1ToL2Alias', () => {
it('should be able to apply the alias to a valid address', () => {
expect(
applyL1ToL2Alias('0x0000000000000000000000000000000000000000')
).to.equal('0x1111000000000000000000000000000000001111')
})
it('should be able to apply the alias even if the operation overflows', () => {
expect(
applyL1ToL2Alias('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')
).to.equal('0x1111000000000000000000000000000000001110')
})
it('should throw if the input is not a valid address', () => {
expect(() => {
applyL1ToL2Alias('0x1234')
}).to.throw('not a valid address: 0x1234')
})
})
describe('undoL1ToL2Alias', () => {
it('should be able to undo the alias from a valid address', () => {
expect(
undoL1ToL2Alias('0x1111000000000000000000000000000000001111')
).to.equal('0x0000000000000000000000000000000000000000')
})
it('should be able to undo the alias even if the operation underflows', () => {
expect(
undoL1ToL2Alias('0x1111000000000000000000000000000000001110')
).to.equal('0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF')
})
it('should throw if the input is not a valid address', () => {
expect(() => {
undoL1ToL2Alias('0x1234')
}).to.throw('not a valid address: 0x1234')
})
})
})