package com.wuban.tron.explore.service.impl;

import com.wuban.tron.explore.BaseTest;
import com.wuban.tron.explore.service.ContractCompilerService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;

class ContractCompilerServiceImplTest extends BaseTest {

    @Autowired
    private ContractCompilerService contractComplierService;

    @BeforeEach
    void setUp() {
    }

    @Test
    void compiler() {
        String name = "Storage2";
        String compiler = "solidity0.4.25+commit";
        String value = "pragma solidity ^0.4.25;\n" +
                "\n" +
                "contract Storage2 {\n" +
                "    uint pos0;\n" +
                "    mapping(address => uint) pos1;\n" +
                "\n" +
                "    function Storage2() {\n" +
                "        pos0 = 12334;\n" +
                "        pos1[msg.sender] = 56278;\n" +
                "    }\n" +
                "    \n" +
                "    function Hello() public returns (string hel) {\n" +
                "        return \"Hello\";\n" +
                "    }\n" +
                "    \n" +
                "    function GetInt() public returns (uint data) {\n" +
                "        return pos0;\n" +
                "    }\n" +
                "    \n" +
                "    function SetInt(uint val) public {\n" +
                "        pos0 = val;\n" +
                "    }\n" +
                "}";
        String str = this.contractComplierService.compiler(name, value, compiler);
        System.out.println(str);
    }

}