@@ -79,19 +79,14 @@ class EthProofServiceSpec
79
79
80
80
" EthProofService" should " return an error when the proof is requested for non-existing account" in new TestSetup {
81
81
val wrongAddress = Address (666 )
82
- val request = GetProofRequest (wrongAddress, storageKeys, blockNumber)
83
- val retrievedAccountProofWrong : ServiceResponse [ProofService .GetProofResponse ] = ethGetProof.getProof(request)
84
- val result = retrievedAccountProofWrong.runSyncUnsafe()
85
-
82
+ val result = fetchProof(wrongAddress, storageKeys, blockNumber).runSyncUnsafe()
86
83
result.isLeft shouldBe true
87
84
result.fold(l => l.message should include(" No account found for Address" ), r => r)
88
85
}
89
86
90
87
" EthProofService" should " return the proof with empty value for non-existing storage key" in new TestSetup {
91
88
val wrongStorageKey = Seq (StorageProofKey (321 ))
92
- val request = GetProofRequest (address, wrongStorageKey, blockNumber)
93
- val retrievedAccountProofWrong : ServiceResponse [ProofService .GetProofResponse ] = ethGetProof.getProof(request)
94
- val result = retrievedAccountProofWrong.runSyncUnsafe()
89
+ val result = fetchProof(address, wrongStorageKey, blockNumber).runSyncUnsafe()
95
90
result.isRight shouldBe true
96
91
result.fold(l => l, r => r.proofAccount.storageProof.map(v => {
97
92
v.proof.nonEmpty shouldBe true
@@ -101,9 +96,7 @@ class EthProofServiceSpec
101
96
102
97
" EthProofService" should " return the proof and value for existing storage key" in new TestSetup {
103
98
val storageKey = Seq (StorageProofKey (key))
104
- val request = GetProofRequest (address, storageKey, blockNumber)
105
- val retrievedAccountProofWrong : ServiceResponse [ProofService .GetProofResponse ] = ethGetProof.getProof(request)
106
- val result = retrievedAccountProofWrong.runSyncUnsafe()
99
+ val result = fetchProof(address, storageKey, blockNumber).runSyncUnsafe()
107
100
result.isRight shouldBe true
108
101
result.fold(l => l, r => r.proofAccount.storageProof.map(v => {
109
102
v.proof.nonEmpty shouldBe true
@@ -114,9 +107,7 @@ class EthProofServiceSpec
114
107
" EthProofService" should " return the proof and value for multiple existing storage keys" in new TestSetup {
115
108
val storageKey = Seq (StorageProofKey (key), StorageProofKey (key2))
116
109
val expectedValueStorageKey = Seq (BigInt (value), BigInt (value2))
117
- val request = GetProofRequest (address, storageKey, blockNumber)
118
- val retrievedAccountProofWrong : ServiceResponse [ProofService .GetProofResponse ] = ethGetProof.getProof(request)
119
- val result = retrievedAccountProofWrong.runSyncUnsafe()
110
+ val result = fetchProof(address, storageKey, blockNumber).runSyncUnsafe()
120
111
result.isRight shouldBe true
121
112
result.fold(l => l, r => {
122
113
r.proofAccount.storageProof.size shouldBe 2
@@ -131,9 +122,7 @@ class EthProofServiceSpec
131
122
val wrongStorageKey = StorageProofKey (321 )
132
123
val storageKey = Seq (StorageProofKey (key), StorageProofKey (key2)) :+ wrongStorageKey
133
124
val expectedValueStorageKey = Seq (BigInt (value), BigInt (value2), BigInt (0 ))
134
- val request = GetProofRequest (address, storageKey, blockNumber)
135
- val retrievedAccountProofWrong : ServiceResponse [ProofService .GetProofResponse ] = ethGetProof.getProof(request)
136
- val result = retrievedAccountProofWrong.runSyncUnsafe()
125
+ val result = fetchProof(address, storageKey, blockNumber).runSyncUnsafe()
137
126
result.isRight shouldBe true
138
127
result.fold(l => l, r => {
139
128
r.proofAccount.storageProof.size shouldBe 3
@@ -188,6 +177,12 @@ class EthProofServiceSpec
188
177
189
178
override lazy val ledger = mock[Ledger ]
190
179
180
+ def fetchProof (address : Address , storageKeys : Seq [StorageProofKey ], blockNumber : BlockParam ): ServiceResponse [ProofService .GetProofResponse ] = {
181
+ val request = GetProofRequest (address, storageKeys, blockNumber)
182
+ val retrievedAccountProofWrong : ServiceResponse [ProofService .GetProofResponse ] = ethGetProof.getProof(request)
183
+ retrievedAccountProofWrong
184
+ }
185
+
191
186
val ethUserService = new EthUserService (
192
187
blockchain,
193
188
ledger,
0 commit comments