| | |
| | | import cc.mrbird.febs.dapp.chain.ChainEnum; |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | | import cc.mrbird.febs.dapp.chain.ContractChainService; |
| | | import cc.mrbird.febs.dapp.contract.andao.AndaoContractMain; |
| | | import cc.mrbird.febs.dapp.entity.DappFundFlowEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappOnlineTransferEntity; |
| | | import cc.mrbird.febs.dapp.enumerate.CardPeriod; |
| | |
| | | import cc.mrbird.febs.dapp.mapper.DappOnlineTransferDao; |
| | | import cc.mrbird.febs.dapp.service.DappSystemService; |
| | | //import cc.mrbird.febs.job.SystemTradeJob; |
| | | import cc.mrbird.febs.dapp.service.impl.BscCoinContractEvent; |
| | | import cc.mrbird.febs.dapp.service.impl.BscUsdtContractEvent; |
| | | import cc.mrbird.febs.job.ProfitDailyJob; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import io.reactivex.disposables.Disposable; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.test.context.SpringBootTest; |
| | | import org.web3j.protocol.Web3j; |
| | | import org.web3j.protocol.core.DefaultBlockParameterNumber; |
| | | import org.web3j.protocol.http.HttpService; |
| | | import org.web3j.protocol.websocket.WebSocketClient; |
| | | import org.web3j.protocol.websocket.WebSocketService; |
| | | import org.web3j.utils.Convert; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.BigInteger; |
| | | import java.math.RoundingMode; |
| | | import java.net.URI; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | @SpringBootTest |
| | | public class ChainTest { |
| | | |
| | | @Test |
| | | public void balanceOfTest() { |
| | | ContractChainService instance = ChainService.getInstance(ChainEnum.BSC_TFC.name()); |
| | | |
| | | System.out.println(instance.balanceOf("0x0000000000000000000000000000000000000001")); |
| | | } |
| | | // @Autowired |
| | | // private BscUsdtContractEvent bscUsdtContractEvent; |
| | | // |
| | | // @Autowired |
| | | // private BscCoinContractEvent bscCoinContractEvent; |
| | | // |
| | | // @Test |
| | | // public void chainListener(){ |
| | | // String address = "0x7BD9454852459EF0314A8631e3f6dD293a4d7044"; |
| | | // BigDecimal amount = new BigDecimal("0.01"); |
| | | // |
| | | // String hash = ChainService.getInstance(ChainEnum.BSC_USDT_W_POOL_CONTRACT.name()).transferUSDT(address, amount); |
| | | // |
| | | // System.out.println(hash); |
| | | // |
| | | // } |
| | | // |
| | | // |
| | | // @Test |
| | | // public void wssChainListener(){ |
| | | // ChainService.wssContractEventListener(new BigInteger("23591200"), bscUsdtContractEvent, ChainEnum.BSC_USDT.name()); |
| | | // } |
| | | // |
| | | // |
| | | // @Test |
| | | // public void wssBaseChainListener(){ |
| | | //// WebSocketService ws = null; |
| | | //// WebSocketClient webSocketClient = null; |
| | | //// Web3j web3j = null; |
| | | // |
| | | // try { |
| | | //// webSocketClient = new WebSocketClient(new URI("wss://bsc-mainnet.nodereal.io/ws/v1/78074065950e4915aef4f12b6f357d16")); |
| | | //// ws = new WebSocketService(webSocketClient, true); |
| | | //// ws.connect(); |
| | | //// web3j = Web3j.build(ws); |
| | | // |
| | | // |
| | | // HttpService service = new HttpService("https://bsc-dataseed1.ninicoin.io"); |
| | | // Web3j web3j = Web3j.build(service); |
| | | // |
| | | //// EthFilter filter = getFilter(startBlock, null, "0xd9076245473060dda1a65f5f3d89a4d0598995e6"); |
| | | //// |
| | | //// Flowable<Log> eventFlowable = web3j.ethLogFlowable(filter); |
| | | //// Disposable subscribe = eventFlowable.subscribe(log -> { |
| | | //// System.out.println(1111111); |
| | | //// System.out.println(log); |
| | | //// }, error -> { |
| | | //// log.error("币安监听异常", error); |
| | | //// }); |
| | | // System.out.println(1111111); |
| | | // Disposable subscription = web3j.blockFlowable(true).subscribe(block -> { |
| | | // System.out.println(111); |
| | | // }, error -> { |
| | | // System.out.println(2222); |
| | | // }); |
| | | // |
| | | //// Disposable subscribe = web3j.replayPastAndFutureTransactionsFlowable(new DefaultBlockParameterNumber(startBlock)).subscribe(tx -> { |
| | | //// System.out.println(1111); |
| | | //// }); |
| | | //// Disposable subscribe = web3j.transactionFlowable().subscribe(tx -> { |
| | | //// System.out.println(1111); |
| | | //// }); |
| | | //// |
| | | //// subscription.dispose(); |
| | | // } catch (Exception e) { |
| | | // System.out.println(2222222); |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | |
| | | // @Autowired |
| | | // private SystemTradeJob systemTradeJob; |
| | | // private ProfitDailyJob profitDailyJob; |
| | | // |
| | | // @Test |
| | | // public void transferPoolTest() { |
| | | // systemTradeJob.transferPoolVol(); |
| | | // public void profitTest() { |
| | | // profitDailyJob.profitDailyJob(); |
| | | // } |
| | | // |
| | | // |
| | | // @Test |
| | | // public void sourceUsdtTest() { |
| | | // systemTradeJob.sourcePoolUsdtOutLimit(); |
| | | // } |
| | | // |
| | | // @Test |
| | | // public void poolTest() { |
| | | // systemTradeJob.transferPoolVol(); |
| | | // } |
| | | |
| | | @Autowired |
| | | private DappOnlineTransferDao dappOnlineTransferDao; |
| | | |
| | | @Test |
| | | public void transferTest() { |
| | | System.out.println(ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(ChainEnum.BSC_USDT_SOURCE.getAddress(), BigDecimal.valueOf(6L))); |
| | | } |
| | | |
| | | @Autowired |
| | | private ChainProducer chainProducer; |
| | | |
| | | @Test |
| | | public void sendTransferTest() { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("batchNo", "678o20scjg5stqf836"); |
| | | map.put("type", "batch"); |
| | | chainProducer.sendOnlineTransfer(JSONObject.toJSONString(map)); |
| | | } |
| | | |
| | | @Test |
| | | public void totalSupplyTest() { |
| | | System.out.println(ChainService.getInstance(ChainEnum.BSC_TFC.name()).blockNumber()); |
| | | } |
| | | |
| | | // @Test |
| | | // public void mineTest() { |
| | | // systemTradeJob.mineJob(); |
| | | // } |
| | | |
| | | @Autowired |
| | | private DappFundFlowDao dappFundFlowDao; |
| | | |
| | | @Test |
| | | public void fundFlowInsertTest() { |
| | | DappFundFlowEntity rewardFlow = new DappFundFlowEntity(11L, BigDecimal.valueOf(1L), 4, 2, BigDecimal.ZERO); |
| | | rewardFlow.setFromHash("1"); |
| | | dappFundFlowDao.insert(rewardFlow); |
| | | } |
| | | |
| | | @Test |
| | | public void userBuyRewardTest() { |
| | | chainProducer.sendUserBuyReward(56L); |
| | | } |
| | | |
| | | @Test |
| | | public void coinDecimalsTest() { |
| | | int decimals = ChainService.getInstance(ChainEnum.BSC_TFC.name()).decimals(); |
| | | BigInteger bigInteger = new BigInteger("110000000000"); |
| | | BigDecimal amount = new BigDecimal(bigInteger.toString()).divide(BigDecimal.TEN.pow(decimals), decimals, RoundingMode.HALF_DOWN); |
| | | System.out.println(amount); |
| | | } |
| | | |
| | | @Autowired |
| | | private DappSystemService dappSystemService; |
| | | |
| | | @Test |
| | | public void profitTest() { |
| | | dappSystemService.tradeProfitDistribute(31L); |
| | | } |
| | | |
| | | @Test |
| | | public void nftBalanceTest() { |
| | | BigDecimal balance = ChainService.getInstance(ChainEnum.BSC_NFT_SDC.name()).balanceOf("0x971c09aa9735eb98459b17ec8b48932d24cbb931"); |
| | | System.out.println(1); |
| | | } |
| | | |
| | | @Test |
| | | public void nftTotalSupplyTest() { |
| | | BigInteger bigInteger = ChainService.getInstance(ChainEnum.BSC_NFT_SDC.name()).totalSupplyNFT(); |
| | | |
| | | int i = CardPeriod.ONE.recommendCnt(bigInteger.intValue()); |
| | | System.out.println(i); |
| | | } |
| | | |
| | | @Autowired |
| | | private BscUsdtContractEvent bscUsdtContractEvent; |
| | | |
| | | @Test |
| | | public void chainListener(){ |
| | | ChainService.contractEventListener(new BigInteger("20058216"), new BigInteger("20058216"), bscUsdtContractEvent, ChainEnum.BSC_USDT.name()); |
| | | } |
| | | } |