/******************************************************************************
* Copyright © 2013-2016 The Nxt Core Developers. *
* *
* See the AUTHORS.txt, DEVELOPER-AGREEMENT.txt and LICENSE.txt files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* Nxt software, including this file, may be copied, modified, propagated, *
* or distributed except according to the terms contained in the LICENSE.txt *
* file. *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
package nxt;
import nxt.crypto.Crypto;
import nxt.util.Time;
import org.junit.Assert;
import org.junit.Test;
import java.util.Properties;
public class ManualForgingTest extends AbstractForgingTest {
@Test
public void manualForgingTest() {
Properties properties = ManualForgingTest.newTestProperties();
properties.setProperty("nxt.enableFakeForging", "true");
properties.setProperty("nxt.timeMultiplier", "1");
AbstractForgingTest.init(properties);
Assert.assertTrue("nxt.fakeForgingAccount must be defined in nxt.properties", Nxt.getStringProperty("nxt.fakeForgingAccount") != null);
final byte[] testPublicKey = Crypto.getPublicKey(testForgingSecretPhrase);
Nxt.setTime(new Time.CounterTime(Nxt.getEpochTime()));
try {
for (int i = 0; i < 10; i++) {
blockchainProcessor.generateBlock(testForgingSecretPhrase, Nxt.getEpochTime());
Assert.assertArrayEquals(testPublicKey, blockchain.getLastBlock().getGeneratorPublicKey());
}
} catch (BlockchainProcessor.BlockNotAcceptedException e) {
throw new RuntimeException(e.toString(), e);
}
Assert.assertEquals(startHeight + 10, blockchain.getHeight());
AbstractForgingTest.shutdown();
}
}