|
19 | 19 | import static com.google.protobuf.ByteString.copyFromUtf8;
|
20 | 20 | import static com.hedera.services.bdd.junit.TestTags.TOKEN;
|
21 | 21 | import static com.hedera.services.bdd.spec.HapiSpec.defaultHapiSpec;
|
22 |
| -import static com.hedera.services.bdd.spec.assertions.AccountDetailsAsserts.accountDetailsWith; |
23 | 22 | import static com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance;
|
24 |
| -import static com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountDetails; |
25 | 23 | import static com.hedera.services.bdd.spec.queries.QueryVerbs.getTokenNftInfo;
|
26 | 24 | import static com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord;
|
27 |
| -import static com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoApproveAllowance; |
28 | 25 | import static com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate;
|
29 | 26 | import static com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer;
|
30 | 27 | import static com.hedera.services.bdd.spec.transactions.TxnVerbs.mintToken;
|
|
42 | 39 | import static com.hedera.services.bdd.spec.transactions.token.HapiTokenReject.rejectingToken;
|
43 | 40 | import static com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving;
|
44 | 41 | import static com.hedera.services.bdd.spec.transactions.token.TokenMovement.movingUnique;
|
45 |
| -import static com.hedera.services.bdd.spec.transactions.token.TokenMovement.movingWithAllowance; |
46 | 42 | import static com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor;
|
47 | 43 | import static com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed;
|
48 | 44 | import static com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext;
|
49 |
| -import static com.hedera.services.bdd.suites.HapiSuite.DEFAULT_PAYER; |
50 |
| -import static com.hedera.services.bdd.suites.HapiSuite.GENESIS; |
51 |
| -import static com.hedera.services.bdd.suites.HapiSuite.ONE_HBAR; |
52 | 45 | import static com.hedera.services.bdd.suites.HapiSuite.ONE_HUNDRED_HBARS;
|
53 | 46 | import static com.hedera.services.bdd.suites.HapiSuite.ONE_MILLION_HBARS;
|
54 | 47 | import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_AMOUNT_TRANSFERS_ONLY_ALLOWED_FOR_FUNGIBLE_COMMON;
|
|
60 | 53 | import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_NFT_ID;
|
61 | 54 | import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_OWNER_ID;
|
62 | 55 | import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE;
|
63 |
| -import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.SPENDER_DOES_NOT_HAVE_ALLOWANCE; |
64 | 56 | import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_IS_PAUSED;
|
65 | 57 | import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT;
|
66 | 58 | import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_REFERENCE_REPEATED;
|
@@ -213,84 +205,6 @@ final Stream<DynamicTest> tokenRejectWorksWithFungibleAndNFTTokens() {
|
213 | 205 | getAccountBalance(TOKEN_TREASURY).logged().hasTokenBalance(FUNGIBLE_TOKEN_A, 1000L));
|
214 | 206 | }
|
215 | 207 |
|
216 |
| - @HapiTest |
217 |
| - final Stream<DynamicTest> tokenRejectWorksWithFungibleAndNFTTokensAndRemovesAllowancesCorrectly() { |
218 |
| - return defaultHapiSpec("tokenRejectWorksWithFungibleAndNFTTokensAndRemovesAllowances") |
219 |
| - .given( |
220 |
| - newKeyNamed(MULTI_KEY), |
221 |
| - cryptoCreate(ACCOUNT).balance(ONE_HUNDRED_HBARS).maxAutomaticTokenAssociations(3), |
222 |
| - cryptoCreate(ACCOUNT_1).maxAutomaticTokenAssociations(3), |
223 |
| - cryptoCreate(SPENDER).balance(ONE_HUNDRED_HBARS).maxAutomaticTokenAssociations(3), |
224 |
| - cryptoCreate(TOKEN_TREASURY), |
225 |
| - tokenCreate(FUNGIBLE_TOKEN_A) |
226 |
| - .initialSupply(TOTAL_SUPPLY) |
227 |
| - .adminKey(MULTI_KEY) |
228 |
| - .supplyKey(MULTI_KEY) |
229 |
| - .treasury(TOKEN_TREASURY), |
230 |
| - tokenCreate(NON_FUNGIBLE_TOKEN_B) |
231 |
| - .initialSupply(0) |
232 |
| - .adminKey(MULTI_KEY) |
233 |
| - .supplyKey(MULTI_KEY) |
234 |
| - .treasury(TOKEN_TREASURY) |
235 |
| - .tokenType(TokenType.NON_FUNGIBLE_UNIQUE), |
236 |
| - tokenAssociate(ACCOUNT, FUNGIBLE_TOKEN_A, NON_FUNGIBLE_TOKEN_B), |
237 |
| - mintToken(NON_FUNGIBLE_TOKEN_B, List.of(copyFromUtf8("memo"), copyFromUtf8("memo"))), |
238 |
| - cryptoTransfer( |
239 |
| - moving(250L, FUNGIBLE_TOKEN_A).between(TOKEN_TREASURY, ACCOUNT), |
240 |
| - movingUnique(NON_FUNGIBLE_TOKEN_B, 1L, 2L).between(TOKEN_TREASURY, ACCOUNT)), |
241 |
| - cryptoApproveAllowance() |
242 |
| - .payingWith(DEFAULT_PAYER) |
243 |
| - .addTokenAllowance(ACCOUNT, FUNGIBLE_TOKEN_A, SPENDER, 200L) |
244 |
| - .addTokenAllowance(TOKEN_TREASURY, FUNGIBLE_TOKEN_A, ACCOUNT, 50L) |
245 |
| - .signedBy(DEFAULT_PAYER, ACCOUNT, SPENDER, TOKEN_TREASURY) |
246 |
| - .fee(ONE_HBAR), |
247 |
| - // Verify Account's allowance works and exists: |
248 |
| - cryptoTransfer(movingWithAllowance(50, FUNGIBLE_TOKEN_A).between(ACCOUNT, ACCOUNT_1)) |
249 |
| - .payingWith(SPENDER) |
250 |
| - .signedBy(SPENDER), |
251 |
| - getAccountDetails(ACCOUNT) |
252 |
| - .payingWith(GENESIS) |
253 |
| - .logged() |
254 |
| - .has(accountDetailsWith().tokenAllowancesContaining(FUNGIBLE_TOKEN_A, SPENDER, 150))) |
255 |
| - .when(withOpContext((spec, opLog) -> allRunFor( |
256 |
| - spec, |
257 |
| - // Try rejecting only when having allowance, without balance |
258 |
| - tokenAssociate(SPENDER, FUNGIBLE_TOKEN_A), |
259 |
| - tokenReject(SPENDER, rejectingToken(FUNGIBLE_TOKEN_A)) |
260 |
| - .hasKnownStatus(INSUFFICIENT_TOKEN_BALANCE), |
261 |
| - tokenReject( |
262 |
| - ACCOUNT, |
263 |
| - rejectingToken(FUNGIBLE_TOKEN_A), |
264 |
| - rejectingNFT(NON_FUNGIBLE_TOKEN_B, 1L), |
265 |
| - rejectingNFT(NON_FUNGIBLE_TOKEN_B, 2L)) |
266 |
| - .via("tokenRejectRemovesAllowance"), |
267 |
| - // Verify Spender's allowance is removed: |
268 |
| - cryptoTransfer(movingWithAllowance(50, FUNGIBLE_TOKEN_A).between(ACCOUNT, ACCOUNT_1)) |
269 |
| - .payingWith(ACCOUNT) |
270 |
| - .signedBy(ACCOUNT) |
271 |
| - .hasKnownStatus(SPENDER_DOES_NOT_HAVE_ALLOWANCE)))) |
272 |
| - .then( |
273 |
| - getTxnRecord("tokenRejectRemovesAllowance") |
274 |
| - .andAllChildRecords() |
275 |
| - .logged(), |
276 |
| - getTokenNftInfo(NON_FUNGIBLE_TOKEN_B, 1L) |
277 |
| - .hasAccountID(TOKEN_TREASURY) |
278 |
| - .hasNoSpender(), |
279 |
| - getTokenNftInfo(NON_FUNGIBLE_TOKEN_B, 2L) |
280 |
| - .hasAccountID(TOKEN_TREASURY) |
281 |
| - .hasNoSpender(), |
282 |
| - getAccountBalance(ACCOUNT).logged().hasTokenBalance(FUNGIBLE_TOKEN_A, 0L), |
283 |
| - getAccountDetails(ACCOUNT) |
284 |
| - .payingWith(GENESIS) |
285 |
| - .logged() |
286 |
| - .has(accountDetailsWith().noAllowances()), |
287 |
| - getAccountDetails(TOKEN_TREASURY) |
288 |
| - .payingWith(GENESIS) |
289 |
| - .logged() |
290 |
| - .has(accountDetailsWith().tokenAllowancesContaining(FUNGIBLE_TOKEN_A, ACCOUNT, 50)), |
291 |
| - getAccountBalance(TOKEN_TREASURY).logged().hasTokenBalance(FUNGIBLE_TOKEN_A, 950L)); |
292 |
| - } |
293 |
| - |
294 | 208 | @HapiTest
|
295 | 209 | final Stream<DynamicTest> tokenRejectCasesWhileFreezeOrPausedOrSigRequired() {
|
296 | 210 | return defaultHapiSpec("tokenRejectWorksWhileFreezeOrPausedOrSigRequired")
|
|
0 commit comments