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