How to use riteway - 10 common examples

To help you get started, we’ve selected a few riteway examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github liquidcarrot / carrot / test / unit.js View on Github external
let { describe, Try } = require('riteway')
let { architect, Network, methods, Neat } = require('../src/index')

describe('filterGenome()', async assert => {
  // total nodes length = 200
  let neat = new Neat(100, 100, null, {
    population_size: 20
  })


  // This replaces bad networks in a population
  const filterGenome = neat.util.filterGenome;

  let pickGenome = function(network) { // takes some input and returns a boolean (true / false)
    return (network.nodes.length > 100) // avoid overfit
  }

  let adjustGenome = function(network) { // a function that takes an object and returns a new form of the object
    return new Network(4, 4) // spit back a new network, 4 in 4 out 8 total
  }
github poetapp / node / tests / functional / transaction_timeout.ts View on Github external
const { bitcoinCoreClientA, bitcoinCoreClientB }: any = bitcoindClients()

const blockHash = lensPath(['anchor', 'blockHash'])
const blockHeight = lensPath(['anchor', 'blockHeight'])
const transactionId = lensPath(['anchor', 'transactionId'])

const getTransactionId = view(transactionId)
const getBlockHash = view(blockHash)
const getBlockHeight = view(blockHeight)
const isNotNil = pipe(isNil, not)

const lengthIsGreaterThan0 = (s: string) => s.length > 0
const hasValidTxId = allPass([is(String), lengthIsGreaterThan0])

describe('Transaction timout will reset the transaction id for the claim', async assert => {
  await resetBitcoinServers()
  await bitcoinCoreClientB.addNode(bitcoinCoreClientA.host, 'add')

  await delayInSeconds(5)

  const { db, server, rabbitMQ } = await setUpServerAndDb({ PREFIX, NODE_PORT, blockchainSettings })

  // Make sure node A has regtest coins to pay for transactions.
  const generatedBlockHeight = 101
  await ensureBitcoinBalance(bitcoinCoreClientA, generatedBlockHeight)
  await waitForBlockchainsToSync(generatedBlockHeight, [bitcoinCoreClientA, bitcoinCoreClientB])
  await bitcoinCoreClientA.setNetworkActive(false)

  // Allow everything to finish starting.
  await delayInSeconds(5)
github liquidcarrot / carrot / test / unit.js View on Github external
expected: 8
  });

  // another case
  assert({
    given: "a population with 20 members",
    should: "return an array of 20",
    actual: filterGenome(neat.population, (new Network(2, 2)), pickGenome, adjustGenome).length,
    expected: 20
  });

  // another case
  assert({
    given: "an pickGenome function that doesn't return a boolean",
    should: 'throw an error',
    actual: Try(filterGenome, neat.population, (new Network(2, 2)), () => { return "a string" }, adjustGenome),
    expected: new Error("pickGenome must always return a boolean!")
  });

  // another case
  assert({
    given: "an adjustGenome function that doesn't return a network",
    should: 'throw an error',
    actual: Try(filterGenome, neat.population, (new Network(2, 2)), pickGenome, () => { return "a string" }),
    expected: new Error('adjustGenome must always return a network!')
  });
});
github liquidcarrot / carrot / test / unit.js View on Github external
expected: 20
  });

  // another case
  assert({
    given: "an pickGenome function that doesn't return a boolean",
    should: 'throw an error',
    actual: Try(filterGenome, neat.population, (new Network(2, 2)), () => { return "a string" }, adjustGenome),
    expected: new Error("pickGenome must always return a boolean!")
  });

  // another case
  assert({
    given: "an adjustGenome function that doesn't return a network",
    should: 'throw an error',
    actual: Try(filterGenome, neat.population, (new Network(2, 2)), pickGenome, () => { return "a string" }),
    expected: new Error('adjustGenome must always return a network!')
  });
});
github paralleldrive / feature-toggles / test / integration / create-express-middleware.js View on Github external
import express from 'express';
import request from 'supertest';
import { describe } from 'riteway';

import { createExpressMiddleware } from '../../src/create-express-middleware';

describe('createExpressMiddleware()', async should => {
  const { assert } = should();
  {
    const app = express();
    const features = ['posts', 'bar', 'foo'];
    const handler = createExpressMiddleware({ features }, 'posts', {
      get: (req, res) => {
        res.send();
      }
    });
    const path = '/posts';
    app.use(path, handler);

    request(app)
      .get(path)
      .end(function(err, res) {
        assert({
github poetapp / node / tests / functional / claim_with_data.ts View on Github external
BATCH_CREATION_INTERVAL_IN_SECONDS: 5,
  READ_DIRECTORY_INTERVAL_IN_SECONDS: 5,
  UPLOAD_CLAIM_INTERVAL_IN_SECONDS: 5,
}

const { configureSignVerifiableClaim } = getVerifiableClaimSigner()
const createVerifiableClaim = configureCreateVerifiableClaim({ issuer })
const signVerifiableClaim = configureSignVerifiableClaim({ privateKey })
const createClaim = pipeP(
  createVerifiableClaim,
  signVerifiableClaim,
)

const { bitcoinCoreClientA, bitcoinCoreClientB }: any = bitcoindClients()

describe('A user can successfully submit a claim into the po.et network', async (assert: any) => {
  await resetBitcoinServers()
  await bitcoinCoreClientB.addNode(bitcoinCoreClientA.host, 'add')
  await delay(5 * 1000)

  const dbA = await createDatabase(PREFIX_A)
  const serverA = await app({
    BITCOIN_URL: bitcoinCoreClientA.host,
    API_PORT: NODE_A_PORT,
    MONGODB_DATABASE: dbA.settings.tempDbName,
    MONGODB_USER: dbA.settings.tempDbUser,
    MONGODB_PASSWORD: dbA.settings.tempDbPassword,
    EXCHANGE_PREFIX: PREFIX_A,
    ...blockchainSettings,
  })

  const dbB = await createDatabase(PREFIX_B)
github poetapp / node / tests / functional / endpoints.ts View on Github external
import { getHealth, getMetrics } from '../helpers/endpoints'
import { delay, runtimeId, createDatabase } from '../helpers/utils'
const Client = require('bitcoin-core')

const PREFIX = `test-functional-node-poet-${runtimeId()}`
const NODE_PORT = '28081'
const LOW_WALLET_BALANCE_IN_BITCOIN = 1
const bitcoindClient = new Client({
  host: process.env.BITCOIN_URL || 'bitcoind-1',
  port: 18443,
  network: 'regtest',
  password: 'bitcoinrpcpassword',
  username: 'bitcoinrpcuser',
})

describe('Health Endpoint Returns the Correct Fields', async (assert: any) => {
  const db = await createDatabase(PREFIX)

  await resetBitcoinServers()
  await delay(5 * 1000)

  const server = await app({
    BITCOIN_URL: process.env.BITCOIN_URL || 'bitcoind-1',
    API_PORT: NODE_PORT,
    MONGODB_DATABASE: db.settings.tempDbName,
    MONGODB_USER: db.settings.tempDbUser,
    MONGODB_PASSWORD: db.settings.tempDbPassword,
    EXCHANGE_PREFIX: PREFIX,
    LOW_WALLET_BALANCE_IN_BITCOIN,
    HEALTH_INTERVAL_IN_SECONDS: 1,
  })
github paralleldrive / react-feature-toggles / test / integration / components.js View on Github external
given: 'feature is inactive',
      should: 'render the inactive component',
      actual: $('.help-inactive').length,
      expected: 1
    });

    assert({
      given: 'feature is inactive',
      should: 'not render the active component',
      actual: $('.help-active').length,
      expected: 0
    });
  }
});

describe('withFeatureToggles and configureFeature', async assert => {
  {
    const FooActive = createTestComponent('foo-active');
    const FooInactive = createTestComponent('foo-inactive');
    const HelpActive = createTestComponent('help-active');
    const HelpInactive = createTestComponent('help-inactive');

    const ConfiguredFoo = configureFeature(FooInactive)('foo')(FooActive);
    const ConfiguredHelp = configureFeature(HelpInactive)('help')(HelpActive);
    const features = ['foo', 'bar'];

    const FooPage = withFeatureToggles({ features })(ConfiguredFoo);
    const HelpPage = withFeatureToggles({ features })(ConfiguredHelp);

    const $ = dom.load(
      render(
        <div></div>
github graphitejs / server / test / functional / app.js View on Github external
import fetch from 'isomorphic-fetch'
import { describe } from 'riteway'
import { Graphite } from '../../src/index'

const options = {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ query: '{ hello }' }),
}

describe('Running Graphite', async assert => {
  {
    const graphite = await Graphite()
    const request = await fetch('http://localhost:4000/graphql', options)

    const actual = (await request.json()).data.hello
    const expected = 'Hello World! 🎉🎉🎉'

    assert({
      given: 'Graphite Server with any configuration',
      should: 'return the default query',
      actual,
      expected,
    })

    await graphite.stop()
  }
github paralleldrive / react-feature-toggles / src / integration / context.js View on Github external
import { describe } from 'riteway';
import dom from 'cheerio';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import createFeature from '../test-fixtures/create-feature';
import { withFeatures, configureFeature } from '../../src';

const render = ReactDOMServer.renderToStaticMarkup;

describe('integration of withFeatures() and configureFeature()', async should => {
  const { assert } = should();

  {
    const initialFeatures = [
      createFeature({
        name: 'comments',
        enabled: false,
        dependencies: []
      }),
      createFeature({
        name: 'help',
        enabled: true,
        dependencies: []
      }),
      createFeature({
        name: 'sorting',

riteway

Unit tests that always supply a good bug report when they fail.

MIT
Latest version published 3 months ago

Package Health Score

66 / 100
Full package analysis

Popular riteway functions

Similar packages