package com.xcong.excoin; 
 | 
  
 | 
import cn.hutool.http.HttpResponse; 
 | 
import cn.hutool.http.HttpUtil; 
 | 
import com.alibaba.fastjson.JSON; 
 | 
import com.xcong.excoin.modules.blackchain.service.Trc20Service; 
 | 
import com.xcong.excoin.utils.RedisUtils; 
 | 
import lombok.extern.slf4j.Slf4j; 
 | 
import org.junit.jupiter.api.Test; 
 | 
import org.springframework.beans.factory.annotation.Autowired; 
 | 
import org.springframework.boot.test.context.SpringBootTest; 
 | 
  
 | 
import javax.annotation.Resource; 
 | 
import java.util.HashMap; 
 | 
import java.util.Map; 
 | 
  
 | 
/** 
 | 
 * @author wzy 
 | 
 * @date 2021-05-04 
 | 
 **/ 
 | 
@Slf4j 
 | 
@SpringBootTest 
 | 
public class TrcTest { 
 | 
  
 | 
    @Autowired 
 | 
    private RedisUtils redisUtils; 
 | 
  
 | 
    @Test 
 | 
    public void trc20Test() { 
 | 
        String url = "https://api.trongrid.io/wallet/getblockbynum"; 
 | 
  
 | 
        while(true) { 
 | 
            Object current = redisUtils.get("USDT_TRC20_CURRENT_BLOCK_NUM"); 
 | 
            Map<String, Object> map = new HashMap<>(); 
 | 
            map.put("num", current); 
 | 
            String param = JSON.toJSONString(map); 
 | 
            System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2"); 
 | 
            HttpResponse response = HttpUtil.createPost(url).body(param).contentType("application/json").header("TRON-PRO-API-KEY", Trc20Service.API_KEY).execute(); 
 | 
//            log.info(response.body()); 
 | 
  
 | 
            try { 
 | 
                Thread.sleep(2000); 
 | 
            } catch (InterruptedException e) { 
 | 
                e.printStackTrace(); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
} 
 |