Search in sources :

Example 1 with CreateAgentTxValidator

use of io.nuls.consensus.poc.tx.validator.CreateAgentTxValidator in project nuls by nuls-io.

the class CreateAgentTxValidatorTest method test.

@Test
public void test() {
    CreateAgentTransaction tx = new CreateAgentTransaction();
    CreateAgentTxValidator validator = new CreateAgentTxValidator();
    ValidateResult result = validator.validate(tx);
    assertFalse(result.isSuccess());
    Agent agent = new Agent();
    tx.setTxData(agent);
    result = validator.validate(tx);
    assertFalse(result.isSuccess());
    byte[] address = AddressTool.getAddress(ecKey.getPubKey());
    byte[] address1 = AddressTool.getAddress(new ECKey().getPubKey());
    byte[] address2 = AddressTool.getAddress(new ECKey().getPubKey());
    agent.setRewardAddress(address);
    agent.setPackingAddress(address1);
    agent.setAgentAddress(address2);
    result = validator.validate(tx);
    assertFalse(result.isSuccess());
    agent.setDeposit(PocConsensusProtocolConstant.AGENT_DEPOSIT_LOWER_LIMIT);
    tx.setTime(System.currentTimeMillis());
    result = validator.validate(tx);
    assertTrue(result.isSuccess());
}
Also used : Agent(io.nuls.consensus.poc.protocol.entity.Agent) CreateAgentTxValidator(io.nuls.consensus.poc.tx.validator.CreateAgentTxValidator) ValidateResult(io.nuls.kernel.validate.ValidateResult) CreateAgentTransaction(io.nuls.consensus.poc.protocol.tx.CreateAgentTransaction) ECKey(io.nuls.core.tools.crypto.ECKey) Test(org.junit.Test) BaseTest(io.nuls.consensus.poc.BaseTest)

Aggregations

BaseTest (io.nuls.consensus.poc.BaseTest)1 Agent (io.nuls.consensus.poc.protocol.entity.Agent)1 CreateAgentTransaction (io.nuls.consensus.poc.protocol.tx.CreateAgentTransaction)1 CreateAgentTxValidator (io.nuls.consensus.poc.tx.validator.CreateAgentTxValidator)1 ECKey (io.nuls.core.tools.crypto.ECKey)1 ValidateResult (io.nuls.kernel.validate.ValidateResult)1 Test (org.junit.Test)1