1
1
'use strict' ;
2
2
3
- const { artifacts, contract } = require ( 'hardhat' ) ;
3
+ const { artifacts, contract, web3 } = require ( 'hardhat' ) ;
4
4
5
5
const { assert } = require ( './common' ) ;
6
6
7
- const { onlyGivenAddressCanInvoke, ensureOnlyExpectedMutativeFunctions } = require ( './helpers' ) ;
7
+ const {
8
+ onlyGivenAddressCanInvoke,
9
+ ensureOnlyExpectedMutativeFunctions,
10
+ getEventByName,
11
+ buildMinimalProxyCode,
12
+ } = require ( './helpers' ) ;
8
13
9
14
const { toBytes32 } = require ( '../..' ) ;
10
15
@@ -73,7 +78,7 @@ contract('ExchangerWithVirtualSynth (unit tests)', async accounts => {
73
78
( ) => {
74
79
behaviors . whenMockedEffectiveRateAsEqual ( ( ) => {
75
80
behaviors . whenMockedLastNRates ( ( ) => {
76
- behaviors . whenMockedASynthToIssueAmdBurn ( ( ) => {
81
+ behaviors . whenMockedASynthToIssueAndBurn ( ( ) => {
77
82
behaviors . whenMockedExchangeStatePersistance ( ( ) => {
78
83
it ( 'it reverts trying to create a virtual synth with no supply' , async ( ) => {
79
84
await assert . revert (
@@ -123,7 +128,7 @@ contract('ExchangerWithVirtualSynth (unit tests)', async accounts => {
123
128
( ) => {
124
129
behaviors . whenMockedEffectiveRateAsEqual ( ( ) => {
125
130
behaviors . whenMockedLastNRates ( ( ) => {
126
- behaviors . whenMockedASynthToIssueAmdBurn ( ( ) => {
131
+ behaviors . whenMockedASynthToIssueAndBurn ( ( ) => {
127
132
behaviors . whenMockedExchangeStatePersistance ( ( ) => {
128
133
describe ( 'when invoked' , ( ) => {
129
134
let txn ;
@@ -147,13 +152,14 @@ contract('ExchangerWithVirtualSynth (unit tests)', async accounts => {
147
152
recipient : owner ,
148
153
} ) ;
149
154
} ) ;
150
- describe ( 'when interrogating the Virtual Synths construction params ' , ( ) => {
155
+ describe ( 'when interrogating the Virtual Synths' , ( ) => {
151
156
let vSynth ;
152
157
beforeEach ( async ( ) => {
153
- const { vSynth : vSynthAddress } = txn . logs . find (
154
- ( { event } ) => event === 'VirtualSynthCreated'
155
- ) . args ;
156
- vSynth = await artifacts . require ( 'VirtualSynth' ) . at ( vSynthAddress ) ;
158
+ const VirtualSynth = artifacts . require ( 'VirtualSynth' ) ;
159
+ vSynth = await VirtualSynth . at (
160
+ getEventByName ( { tx : txn , name : 'VirtualSynthCreated' } ) . args
161
+ . vSynth
162
+ ) ;
157
163
} ) ;
158
164
it ( 'the vSynth has the correct synth' , async ( ) => {
159
165
assert . equal (
@@ -175,6 +181,13 @@ contract('ExchangerWithVirtualSynth (unit tests)', async accounts => {
175
181
) ;
176
182
assert . equal ( this . mocks . synth . smocked . issue . calls [ 0 ] [ 1 ] , amount ) ;
177
183
} ) ;
184
+ it ( 'the vSynth is an ERC-1167 minimal proxy instead of a full Virtual Synth' , async ( ) => {
185
+ const vSynthCode = await web3 . eth . getCode ( vSynth . address ) ;
186
+ assert . equal (
187
+ vSynthCode ,
188
+ buildMinimalProxyCode ( this . mocks . VirtualSynthMastercopy . address )
189
+ ) ;
190
+ } ) ;
178
191
} ) ;
179
192
} ) ;
180
193
} ) ;
0 commit comments