Coder Social home page Coder Social logo

test-task-march-2022's Introduction

Trial Chain mock

In addition to the design doc, there are also:

Build

stack build

Run

Important notes:

  • no logging
  • hardcoded port 8081
  • both server and test start with hardcoded magic "bank" account which contains large quantity of money for testing;
stack run server-exe

You can make sure the server is running using curl:

curl http://localhost:8081/alive

Test

Unit tests and api tests:

stack test

Manual testing

You can generate signed transactions by using ghci:

$ stack repl src/TrialChain/Signature.hs

import Data.Aeson
putStrLn . encode $ _testSignTx "bank" "pedro" 100 ""

{"body": ...

And send requests by REST client of your choice:

PUT http://localhost:8081/tx
Content-type: application/json

{"body":{"from":"bank","to":"pedro","amount":100,"nonce":""},"signature":"signed-by-bank-90d2e36e37adaaa5fbe854f77b02837c"}

Profiling

Done manually. Build sever with profiling, run load-test, analyze profiles manually.

Hunting down memory leaks:

stack run --profile server-exe -- +RTS  -hy -l-agu -RTS
eventlog2html server-exe.eventlog && firefox server-exe.eventlog.html

Hunting down performance bottlenecks:

stack run --profile server-exe -- +RTS -p -RTS
ghc-prof-flamegraph server-exe.prof && firefox firefox server-exe.svg

Running a tester.

stack run load-test-exe

Coding style

Prefer explicit imports. Format using ormolu. Make sure ormolu is runnable and execute sh ./format.sh.

A hack to copy tools from a current workspace into stack's global bin directory and add it to PATH:

copy-stack-tools() {
    stack build --copy-compiler-tool hlint hoogle weeder hindent ghcid ormolu .
}

stackify() {
    compiler_bin=$(stack path --compiler-bin)
    compiler_tools_bin=$(stack path --compiler-tools-bin)
    if [ ! -d $compiler_tools_bin ]; then
        copy-stack-tools
    fi
    if [ ! -d $compiler_bin ]; then
        stack build --install-ghc
    fi
    PATH=$compiler_bin:$compiler_tools_bin:$PATH
}

test-task-march-2022's People

Contributors

kevroletin avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.