Skip to content

Commit

Permalink
Merge pull request #184 from defi-wonderland/dev
Browse files Browse the repository at this point in the history
chore: v2.3.5
  • Loading branch information
0xGorilla authored Jun 22, 2023
2 parents a5afb60 + 55212cd commit 9cbac21
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/source/fakes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ When should I use a fake?
-------------------------

Fakes are a powerful tool when you want to test how a smart contract will interact with other contracts.
Instead of initalizing a full-fledged smart contract to interact with, you can simply create a fake that can provide pre-programmed responses.
Instead of initializing a full-fledged smart contract to interact with, you can simply create a fake that can provide pre-programmed responses.

Fakes are especially useful when the contracts that you need to interact with are relatively complex.
For example, imagine that you're testing a contract that needs to interact with another (very stateful) contract.
Expand Down
10 changes: 10 additions & 0 deletions docs/source/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,13 @@ If you'd like to use mocks, you **must** update your :code:`hardhat.config.<js/t
}
export default config
Optional config to use Smock Matchers
-------------------------------------


.. code-block:: typescript
// ContractTest.ts
import { smock } from '@defi-wonderland/smock';
chai.use(smock.matchers);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@defi-wonderland/smock",
"version": "2.3.4",
"version": "2.3.5",
"description": "The Solidity mocking library",
"keywords": [
"ethereum",
Expand Down
8 changes: 8 additions & 0 deletions src/utils/hardhat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ export const getHardhatBaseProvider = async (runtime: HardhatRuntimeEnvironment)
// Search by looking for the internal "_wrapped" variable. Base provider doesn't have this
// property (at least for now!).
let provider: any = runtime.network.provider;

if ('init' in provider) {
// Newer versions of Hardhat initialize the provider lazily, so we need to
// call provider.init() explicitly. This is a no-op if the provider is
// already initialized.
await provider.init();
}

while (provider._wrapped !== undefined) {
provider = provider._wrapped;

Expand Down

0 comments on commit 9cbac21

Please sign in to comment.