package leigh.chain.msg;

import leigh.mecha.json.JSONObject;
import leigh.mecha.log.MechaLogger;
import leigh.mecha.log.MechaLoggerFactory;
import org.junit.jupiter.api.Test;
import org.web3j.crypto.CipherException;

import java.io.IOException;
import java.security.SignatureException;

public class SignedMessageTest {
    private static final MechaLogger logger = MechaLoggerFactory.getLogger(SignedMessageTest.class);
    private final String PW = "eHjbwCJRe4mLHDuY";
    private final String FN = "../keystore/UTC--2022-03-30T23-25-32.462178000Z--6bdb22c0897cc0d0dbf3942b33e28adf3c6f98be";

    @Test
    public void testThing() throws CipherException, IOException, SignatureException {
        SignedMessage msg = new SignedMessage();

        JSONObject m = new JSONObject();
        m.put("firstName", "Alex");
        m.put("lastName", "Leigh");
        msg.setContent(m.toString());
        msg.sign(FN, PW);

        logger.info("Generated signed message: {}", msg.getJSONEnvelope());
    }
}
