Skip to content

Commit e34353b

Browse files
committed
clean up fallback and receive tests
1 parent 2074e7d commit e34353b

File tree

4 files changed

+40
-6
lines changed

4 files changed

+40
-6
lines changed

spec/proxy/Proxy.behavior.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,17 @@ export function describeBehaviorOfProxy(
3939
});
4040

4141
describe('receive()', () => {
42-
it('forwards value to implementation');
42+
it('forwards value to implementation via delegatecall', async () => {
43+
// TODO: receive tests pass because hardhat-exposed functions used as implementations are payable
44+
const [signer] = await ethers.getSigners();
45+
46+
await expect(
47+
signer.sendTransaction({
48+
to: await instance.getAddress(),
49+
value: 1n,
50+
}),
51+
).not.to.be.reverted;
52+
});
4353
});
4454
});
4555
}

spec/proxy/diamond/DiamondProxy.behavior.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describeFilter } from '@solidstate/library';
2-
import { ProxyBehaviorArgs } from '@solidstate/spec';
2+
import { describeBehaviorOfProxy, ProxyBehaviorArgs } from '@solidstate/spec';
33
import { IDiamondProxy } from '@solidstate/typechain-types';
44
import { expect } from 'chai';
55
import { ethers } from 'hardhat';
@@ -20,6 +20,8 @@ export function describeBehaviorOfDiamondProxy(
2020
instance = await deploy();
2121
});
2222

23+
describeBehaviorOfProxy(deploy, args, skips);
24+
2325
describe('fallback()', () => {
2426
it('forwards data with matching selector call to facet', async () => {
2527
expect(instance.interface.hasFunction(args.implementationFunction)).to

spec/proxy/diamond/fallback/DiamondProxyFallback.behavior.ts

+25-3
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,36 @@ export function describeBehaviorOfDiamondProxyFallback(
3131
nonOwner = await args.getNonOwner();
3232
});
3333

34-
describeBehaviorOfDiamondProxy(async () => instance, args, skips);
34+
describeBehaviorOfDiamondProxy(async () => instance, args, [
35+
'receive()',
36+
...(skips ?? []),
37+
]);
3538

3639
describe('fallback()', () => {
37-
it('forwards data without matching selector to fallback contract');
40+
it('forwards data without matching selector to fallback contract', async () => {
41+
await expect(
42+
owner.sendTransaction({
43+
to: await instance.getAddress(),
44+
}),
45+
).to.be.revertedWithCustomError(
46+
instance,
47+
'Proxy__ImplementationIsNotContract',
48+
);
49+
});
3850
});
3951

4052
describe('receive()', () => {
41-
it('forwards value to fallback contract');
53+
it('forwards value to fallback contract', async () => {
54+
await expect(
55+
owner.sendTransaction({
56+
to: await instance.getAddress(),
57+
value: 1n,
58+
}),
59+
).to.be.revertedWithCustomError(
60+
instance,
61+
'Proxy__ImplementationIsNotContract',
62+
);
63+
});
4264
});
4365

4466
describe('#getFallbackAddress()', () => {

test/proxy/diamond/SolidstateDiamondProxy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ describe('SolidstateDiamondProxy', () => {
5454
fallbackAddress: ethers.ZeroAddress,
5555
immutableSelectors,
5656
},
57-
['fallback()'],
57+
['fallback()', 'receive()'],
5858
);
5959
});

0 commit comments

Comments
 (0)