doppelgänger /ˈdɒp(ə)lˌɡaŋə,ˈdɒp(ə)lˌɡɛŋə/ - an apparition or double of a living person
Library for mocking smart contract dependencies during unit testing.
To start using with npm, type:
npm i -D ethereum-doppelganger
or with Yarn:
yarn add --dev ethereum-doppelganger
Doppelganger is currently developed to work with ethers-js exclusively. Support for other framework will be added in a future version.
Create a instance of Doppelganger
providing the ABI/interface of the smart contract you want to mock:
import Doppelganger from 'ethereum-doppelganger';
...
const doppelganger = new Doppelganger(abi);
Deploy a instance of the Doppelganger smart contract:
await doppelganger.deploy(wallet);
Doppelganger can now be passed into other contracts by using the address
attribute.
Return values for mocked functions can be set using:
await doppelganger.<nameOfMethod>.returns(<value>)