@@ -3152,6 +3152,77 @@ var runTests = function(contractFactory) {
3152
3152
describe ( 'typical usage' , function ( ) {
3153
3153
runTests ( getEthContractInstance ) ;
3154
3154
3155
+ it ( 'should not mutate options object - call' , function ( done ) {
3156
+ var provider = new FakeHttpProvider ( ) ;
3157
+
3158
+ provider . injectResult ( '0x0000000000000000000000000000000000000000000000000000000000000032' ) ;
3159
+
3160
+ var eth = new Eth ( provider ) ;
3161
+ var contract = new eth . Contract ( abi , address ) ;
3162
+ var options = { from : address } ;
3163
+ var expectedOptions = { ...options } ;
3164
+
3165
+ contract . methods . balance ( address ) . call ( options )
3166
+ . then ( function ( ) {
3167
+ assert . deepEqual ( options , expectedOptions ) ;
3168
+ done ( ) ;
3169
+ } ) ;
3170
+ } ) ;
3171
+
3172
+ it ( 'should not mutate options object - send' , function ( done ) {
3173
+ var provider = new FakeHttpProvider ( ) ;
3174
+
3175
+ provider . injectResult ( '0x1234000000000000000000000000000000000000000000000000000000056789' ) ;
3176
+ provider . injectResult ( {
3177
+ contractAddress : null ,
3178
+ cumulativeGasUsed : '0xa' ,
3179
+ transactionIndex : '0x3' ,
3180
+ transactionHash : '0x1234' ,
3181
+ blockNumber : '0xa' ,
3182
+ blockHash : '0x1234' ,
3183
+ gasUsed : '0x0' ,
3184
+ logs : [ {
3185
+ address : address ,
3186
+ topics : [
3187
+ sha3 ( 'Unchanged(uint256,address,uint256)' ) ,
3188
+ '0x0000000000000000000000000000000000000000000000000000000000000002' ,
3189
+ '0x000000000000000000000000' + addressLowercase . replace ( '0x' , '' )
3190
+ ] ,
3191
+ blockNumber : '0xa' ,
3192
+ transactionHash : '0x1234' ,
3193
+ transactionIndex : '0x0' ,
3194
+ blockHash : '0x1345' ,
3195
+ logIndex : '0x4' ,
3196
+ data : '0x0000000000000000000000000000000000000000000000000000000000000005'
3197
+ } , {
3198
+ address : address ,
3199
+ topics : [
3200
+ sha3 ( 'Changed(address,uint256,uint256,uint256)' ) ,
3201
+ '0x000000000000000000000000' + addressLowercase . replace ( '0x' , '' ) ,
3202
+ '0x0000000000000000000000000000000000000000000000000000000000000001'
3203
+ ] ,
3204
+ blockNumber : '0xa' ,
3205
+ transactionHash : '0x1234' ,
3206
+ transactionIndex : '0x0' ,
3207
+ blockHash : '0x1345' ,
3208
+ logIndex : '0x4' ,
3209
+ data : '0x0000000000000000000000000000000000000000000000000000000000000001' +
3210
+ '0000000000000000000000000000000000000000000000000000000000000008'
3211
+ } ]
3212
+ } ) ;
3213
+
3214
+ var eth = new Eth ( provider ) ;
3215
+ var contract = new eth . Contract ( abi , address ) ;
3216
+ var options = { from : address , gasPrice : '21345678654321' } ;
3217
+ var expectedOptions = { ...options } ;
3218
+
3219
+ contract . methods . mySend ( address , 10 ) . send ( options )
3220
+ . on ( 'receipt' , function ( ) {
3221
+ assert . deepEqual ( options , expectedOptions ) ;
3222
+ done ( ) ;
3223
+ } ) ;
3224
+ } ) ;
3225
+
3155
3226
it ( 'should update contract instance provider when assigned a provider to eth instance that contract instance came from' , function ( ) {
3156
3227
var provider1 = new FakeIpcProvider ( ) ;
3157
3228
var provider2 = new FakeHttpProvider ( ) ;
0 commit comments