@@ -8,28 +8,32 @@ import { Chain } from '../../chains/constants';
8
8
import { PufferVaultHandler } from './puffer-vault-handler' ;
9
9
10
10
describe ( 'PufferVaultHandler' , ( ) => {
11
- it ( 'should check pufETH balance' , async ( ) => {
12
- const mockAddress = '0x8d37d81e29d11cd7557ceaca25e4e4a4255b1159' ;
13
- const mockBalance = BigInt ( 1 ) ;
14
- const mockCallHex = toHex ( mockBalance , { size : 32 } ) ;
11
+ it ( 'should deposit ETH' , async ( ) => {
12
+ const mockAddress = '0xEB77D02f8122B32273444a1b544C147Fb559CB41' ;
13
+ const mockGas = BigInt ( 1 ) ;
15
14
16
- const walletClient = setupMockWalletClient ( ) ;
17
- const publicRequest = mockRpcRequest ( { eth_call : mockCallHex } ) ;
15
+ const walletRequest = mockRpcRequest ( {
16
+ eth_sendTransaction : mockAddress ,
17
+ } ) ;
18
+ const walletClient = setupMockWalletClient ( walletRequest ) ;
19
+ const publicRequest = mockRpcRequest ( { eth_estimateGas : mockGas } ) ;
18
20
const publicClient = setupMockPublicClient ( publicRequest ) ;
19
21
20
22
const handler = new PufferVaultHandler (
21
23
Chain . Anvil ,
22
24
walletClient ,
23
25
publicClient ,
24
26
) ;
25
- const balance = await handler . balanceOf ( mockAddress ) ;
27
+ const { transact , estimate } = handler . depositETH ( mockAddress ) ;
26
28
27
- expect ( balance ) . toBe ( mockBalance ) ;
29
+ expect ( await transact ( BigInt ( 1 ) ) ) . toBe ( mockAddress ) ;
30
+ expect ( await estimate ( ) ) . toBe ( mockGas ) ;
28
31
} ) ;
29
32
30
- it ( 'should be able to deposit ETH ' , async ( ) => {
33
+ it ( 'should deposit stETH ' , async ( ) => {
31
34
const mockAddress = '0xEB77D02f8122B32273444a1b544C147Fb559CB41' ;
32
35
const mockGas = BigInt ( 1 ) ;
36
+ const mockValue = BigInt ( 1 ) ;
33
37
34
38
const walletRequest = mockRpcRequest ( {
35
39
eth_sendTransaction : mockAddress ,
@@ -43,9 +47,67 @@ describe('PufferVaultHandler', () => {
43
47
walletClient ,
44
48
publicClient ,
45
49
) ;
46
- const { transact, estimate } = handler . depositETH ( mockAddress ) ;
50
+ const { transact, estimate } = handler . depositStETH ( mockAddress , mockValue ) ;
47
51
48
- expect ( await transact ( BigInt ( 1 ) ) ) . toBe ( mockAddress ) ;
52
+ expect ( await transact ( ) ) . toBe ( mockAddress ) ;
49
53
expect ( await estimate ( ) ) . toBe ( mockGas ) ;
50
54
} ) ;
55
+
56
+ it ( 'should check pufETH balance' , async ( ) => {
57
+ const mockAddress = '0xEB77D02f8122B32273444a1b544C147Fb559CB41' ;
58
+ const mockBalance = BigInt ( 1 ) ;
59
+ const mockCallHex = toHex ( mockBalance , { size : 32 } ) ;
60
+
61
+ const walletClient = setupMockWalletClient ( ) ;
62
+ const publicRequest = mockRpcRequest ( { eth_call : mockCallHex } ) ;
63
+ const publicClient = setupMockPublicClient ( publicRequest ) ;
64
+
65
+ const handler = new PufferVaultHandler (
66
+ Chain . Anvil ,
67
+ walletClient ,
68
+ publicClient ,
69
+ ) ;
70
+ const balance = await handler . balanceOf ( mockAddress ) ;
71
+
72
+ expect ( balance ) . toBe ( mockBalance ) ;
73
+ } ) ;
74
+
75
+ it ( 'should check pufETH rate' , async ( ) => {
76
+ const mockRate = BigInt ( 1e18 ) ;
77
+ const mockCallHex = toHex ( mockRate , { size : 32 } ) ;
78
+
79
+ const walletClient = setupMockWalletClient ( ) ;
80
+ const publicRequest = mockRpcRequest ( { eth_call : mockCallHex } ) ;
81
+ const publicClient = setupMockPublicClient ( publicRequest ) ;
82
+
83
+ const handler = new PufferVaultHandler (
84
+ Chain . Anvil ,
85
+ walletClient ,
86
+ publicClient ,
87
+ ) ;
88
+ const rate = await handler . getPufETHRate ( ) ;
89
+
90
+ expect ( rate ) . toBe ( mockRate ) ;
91
+ } ) ;
92
+
93
+ it ( 'should get allowance' , async ( ) => {
94
+ const mockAllowance = BigInt ( 1 ) ;
95
+ const mockCallHex = toHex ( mockAllowance , { size : 32 } ) ;
96
+
97
+ const walletClient = setupMockWalletClient ( ) ;
98
+ const publicRequest = mockRpcRequest ( { eth_call : mockCallHex } ) ;
99
+ const publicClient = setupMockPublicClient ( publicRequest ) ;
100
+
101
+ const handler = new PufferVaultHandler (
102
+ Chain . Anvil ,
103
+ walletClient ,
104
+ publicClient ,
105
+ ) ;
106
+ const rate = await handler . getAllowance (
107
+ '0xEB77D02f8122B32273444a1b544C147Fb559CB41' ,
108
+ '0x92e01fbccae21eed10ab2f278f47905d482df202' ,
109
+ ) ;
110
+
111
+ expect ( rate ) . toBe ( mockAllowance ) ;
112
+ } ) ;
51
113
} ) ;
0 commit comments