Search in sources :

Example 21 with Config

use of com.icodici.universa.node2.Config in project jdk8u_jdk by JetBrains.

the class Duplicates method main.

public static void main(String[] args) throws Exception {
    System.setProperty("java.security.krb5.conf", System.getProperty("test.src", ".") + "/k1.conf");
    Config config = Config.getInstance();
    config.listTable();
    String s;
    // Latter overwrites former for root section
    s = config.get("libdefaults", "default_realm");
    if (s != null) {
        throw new Exception();
    }
    // Latter overwrites former for strings
    s = config.get("libdefaults", "default_tkt_enctypes");
    if (!s.equals("aes256-cts")) {
        throw new Exception();
    }
    // Latter overwrites former for sub-section
    s = config.get("realms", "R1", "kdc");
    if (!s.equals("k2")) {
        throw new Exception(s);
    }
    // Duplicate keys in [realms] are merged
    s = config.getAll("realms", "R2", "kdc");
    if (!s.equals("k1 k2 k3 k4")) {
        throw new Exception(s);
    }
    // Duplicate keys in [capaths] are merged
    s = config.getAll("capaths", "R1", "R2");
    if (!s.equals("R3 R4 R5 R6")) {
        throw new Exception(s);
    }
    // We can be very deep now
    s = config.get("new", "x", "y", "z", "a", "b", "c");
    if (!s.equals("d")) {
        throw new Exception(s);
    }
}
Also used : Config(sun.security.krb5.Config)

Example 22 with Config

use of com.icodici.universa.node2.Config in project controller by opendaylight.

the class TracingBrokerTest method testPrintOpenTransactions.

@Test
// Finding resource leaks is the point of this test
@SuppressWarnings({ "resource", "unused" })
public void testPrintOpenTransactions() {
    DOMDataBroker domDataBroker = mock(DOMDataBroker.class, RETURNS_DEEP_STUBS);
    Config config = new ConfigBuilder().setTransactionDebugContextEnabled(true).build();
    BindingNormalizedNodeSerializer codec = mock(BindingNormalizedNodeSerializer.class);
    TracingBroker tracingBroker = new TracingBroker(domDataBroker, config, codec);
    DOMDataReadWriteTransaction tx = tracingBroker.newReadWriteTransaction();
    DOMTransactionChain txChain = tracingBroker.createTransactionChain(null);
    DOMDataReadWriteTransaction txFromChain = txChain.newReadWriteTransaction();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    boolean printReturnValue = tracingBroker.printOpenTransactions(ps);
    String output = new String(baos.toByteArray(), UTF_8);
    assertThat(printReturnValue).isTrue();
    // Assert expections about stack trace
    assertThat(output).contains("testPrintOpenTransactions(TracingBrokerTest.java");
    assertThat(output).doesNotContain(TracingBroker.class.getName());
    String previousLine = "";
    for (String line : output.split("\n")) {
        if (line.contains("(...")) {
            assertThat(previousLine.contains("(...)")).isFalse();
        }
        previousLine = line;
    }
// We don't do any verify/times on the mocks,
// because the main point of the test is just to verify that
// printOpenTransactions runs through without any exceptions
// (e.g. it used to have a ClassCastException).
}
Also used : PrintStream(java.io.PrintStream) DOMDataReadWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction) Config(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsaltrace.rev160908.Config) ConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsaltrace.rev160908.ConfigBuilder) BindingNormalizedNodeSerializer(org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TracingBroker(org.opendaylight.controller.md.sal.trace.dom.impl.TracingBroker) DOMTransactionChain(org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain) DOMDataBroker(org.opendaylight.controller.md.sal.dom.api.DOMDataBroker) Test(org.junit.Test)

Example 23 with Config

use of com.icodici.universa.node2.Config in project universa by UniversaBlockchain.

the class SlotContractTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    nodeConfig = new Config();
    nodeConfig.addTransactionUnitsIssuerKeyData(new KeyAddress("Zau3tT8YtDkj3UDBSznrWHAjbhhU4SXsfQLWDFsv5vw24TLn6s"));
}
Also used : Config(com.icodici.universa.node2.Config) KeyAddress(com.icodici.crypto.KeyAddress) BeforeClass(org.junit.BeforeClass)

Example 24 with Config

use of com.icodici.universa.node2.Config in project universa by UniversaBlockchain.

the class FollowerContractTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    nodeConfig = new Config();
    nodeConfig.addTransactionUnitsIssuerKeyData(new KeyAddress("Zau3tT8YtDkj3UDBSznrWHAjbhhU4SXsfQLWDFsv5vw24TLn6s"));
}
Also used : Config(com.icodici.universa.node2.Config) KeyAddress(com.icodici.crypto.KeyAddress) BeforeClass(org.junit.BeforeClass)

Example 25 with Config

use of com.icodici.universa.node2.Config in project universa by UniversaBlockchain.

the class Main method startNode.

private void startNode() throws SQLException, IOException {
    // Minimum size of network is 10. Smaller configurations are treated as test networks.
    // For such configurations we are using table data rather than formula
    config.setConsensusConfigUpdater((config, n) -> {
        int negative;
        int positive;
        if (n < 3) {
            negative = 1;
            positive = n;
        } else if (n < 10) {
            negative = 2;
            positive = n - 1;
        } else {
            positive = (int) Math.ceil(n * 0.9);
            negative = n + 1 - positive;
        }
        int resyncBreak = (int) Math.ceil(n * 0.2);
        if (resyncBreak < 1)
            resyncBreak = 1;
        if (resyncBreak + positive == n)
            resyncBreak += 1;
        log(myInfo.getNumber() + ": Network consensus is set to (negative/positive/resyncBreak): " + negative + " / " + positive + " / " + resyncBreak);
        config.setPositiveConsensus(positive);
        config.setNegativeConsensus(negative);
        config.setResyncBreakConsensus(resyncBreak);
    });
    network = new NetworkV2(netConfig, myInfo, nodeKey);
    node = new Node(config, myInfo, ledger, network, nodeKey, new File(configRoot + "/config/contracts"));
    cache = node.getCache();
    parcelCache = node.getParcelCache();
    paidOperationCache = node.getPaidOperationCache();
    envCache = node.getEnvCache();
    StateRecord r = ledger.getRecord(HashId.withDigest("bS/c4YMidaVuzTBhHLkGPFAvPbZQHybzQnXAoBwaZYM8eLYb7mAkVYEpuqKRXYc7anqX47BeNdvFN1n7KluH9A=="));
    if (r != null)
        r.destroy();
    clientHTTPServer.setConfig(config);
    clientHTTPServer.setNode(node);
    clientHTTPServer.setCache(cache);
    clientHTTPServer.setParcelCache(parcelCache);
    clientHTTPServer.setPaidOperationCache(paidOperationCache);
    clientHTTPServer.setEnvCache(envCache);
    clientHTTPServer.setLocalCors(myInfo.getPublicHost().equals("localhost"));
}
Also used : StateRecord(com.icodici.universa.node.StateRecord) File(java.io.File) NetworkV2(com.icodici.universa.node2.network.NetworkV2)

Aggregations

Config (sun.security.krb5.Config)8 Test (org.junit.Test)7 IOException (java.io.IOException)6 Config (simplelibrary.config2.Config)6 KeyAddress (com.icodici.crypto.KeyAddress)5 File (java.io.File)5 TimeoutException (java.util.concurrent.TimeoutException)4 Before (org.junit.Before)3 Timeout (akka.util.Timeout)2 PrivateKey (com.icodici.crypto.PrivateKey)2 com.icodici.universa.contract (com.icodici.universa.contract)2 QuorumVoteRole (com.icodici.universa.contract.roles.QuorumVoteRole)2 com.icodici.universa.contract.services (com.icodici.universa.contract.services)2 Config (com.icodici.universa.node2.Config)2 EventExecutor (io.netty.util.concurrent.EventExecutor)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ZonedDateTime (java.time.ZonedDateTime)2 java.util (java.util)2 HashSet (java.util.HashSet)2 java.util.concurrent (java.util.concurrent)2