Skip to content

Commit

Permalink
Cleaning and readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Xalava authored and jotapero committed Jan 23, 2023
1 parent b4a1d20 commit b9187e3
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 207 deletions.
12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# Draft files (to be removed)
*.sl.*
# Draft files and solutions
dft*
*.sol
student*

## Potential key files
*.txt
*.pem
*.cer
*key*

## Typical unecessary files & folders
package-lock.json
node_modules/
.vscode
pnpm-lock.yaml

## build folders & files
## Build folders & files (should not be necessary when everyting is run in docker)
build/
artifacts/
cache/
coverage/
coverage.json
bin/
bin/
solc
11 changes: 5 additions & 6 deletions introductions.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You should not use any crypto with value for any exercise of the module. If you
1. [sendTransaction](sendTransaction/README.md) _Send a Bitcoin transaction_
2. [retrieveBlockDate](retrieveBlockDate/README.md) _get a block date_
3. [retrieveTransactionValue](retrieveTransactionValue/README.md) _get the value of a transaction_
4. [sendTransactionToPeer](sendTransactionToPeer/README.md) _send a bitcoin transaction to a peer
4. [sendTransactionToPeer](sendTransactionToPeer/README.md) _send a bitcoin transaction to a peer_
5. [sendEthTransaction](sendEthTransaction/README.md) _Send a transaction to an address on a testnet_

#### Optional
Expand Down Expand Up @@ -74,8 +74,7 @@ node test.mjs <exercices>

### Festival Smart Contract Quest

*We didn't take the Bastille to make an opera out of it! -
Pierre Desproges*
*We didn't take the Bastille to make an opera out of it! - Pierre Desproges*

Today we will build our first Smart Contracts. Smart Contracts are programs deployed on a blockchain network to provide additional functionalities. In the context of this quest, we will focus on Ethereum Smart Contracts. There main development language is Solidity.

Expand Down Expand Up @@ -116,7 +115,7 @@ npx hardhat test tests/<exercise>.test.js

### Anchoring

A simple use of blockhains is to anchor documents. We will hash documents and store them in a blockchain.
A simple use of blockchains is to anchor documents. We will hash documents and store them in a blockchain.

For this, we will use a local test node and interact with it using JavaScript

Expand Down Expand Up @@ -255,9 +254,9 @@ In addition, each token is linked to an Uniform Resource Identifier (URI) where

*I accidentally killed it - devops199*

It is time for us to advance beyond basic contracts for integrate with actual DeFi smart contrat. For this we will need to use current standards and implementations.
It is time for us to advance beyond basic contracts for integrate with actual DeFi smart contract. For this we will need to use current standards and implementations.

First, we will create a simple stablecoin, following the ERC20 standart and an oracle. We will then create a decentralised exchange that will allow us to exchange our stablecoin. Finally, we will create the tests for this project.
First, we will create a simple stablecoin, following the ERC20 standard and an oracle. We will then create a decentralised exchange that will allow us to exchange our stablecoin. Finally, we will create the tests for this project.

#### Content
1. [stablecoin](stablecoin/README.md)
Expand Down
5 changes: 0 additions & 5 deletions tests/.gitignore

This file was deleted.

20 changes: 10 additions & 10 deletions tests/btc/retrieve-block-date.test.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
const { expect } = require("chai");
const Client = require('bitcoin-core');
const {retrieveBlockDate}= require("/jail/student/retrieve-block-date.js")
const { expect } = require("chai")
const Client = require('bitcoin-core')
const { retrieveBlockDate } = require("/jail/student/retrieve-block-date.js")

describe("retrieve block date", function() {
describe("retrieve block date", function () {
let client, hashLatest, timeLatest

beforeEach( async function () {
client = new Client({
network: 'regtest',
username: 'leeloo',
password: 'multipass',
beforeEach(async function () {
client = new Client({
network: 'regtest',
username: 'leeloo',
password: 'multipass',
port: 18443 //18445
})
hashLatest = await client.getBestBlockHash()
let block = await client.getBlock(hashLatest)
timeLatest = block.time
})

it("latest block is ok", async function() {
it("latest block is ok", async function () {
let retrievedTime = await retrieveBlockDate(hashLatest)
expect(retrievedTime).to.equal(timeLatest)
})
Expand Down
28 changes: 14 additions & 14 deletions tests/btc/retrieve-transaction-in-out.test.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
const { expect } = require("chai");
const Client = require('bitcoin-core');
const {retrieveTransactionInOut}= require("/jail/student/retrieve-transaction-in-out.js")
const { expect } = require("chai")
const Client = require('bitcoin-core')
const { retrieveTransactionInOut } = require("/jail/student/retrieve-transaction-in-out.js")

describe("retrieve transaction ins and outs", function() {
describe("retrieve transaction ins and outs", function () {
let client, hashLatest, txLatest

beforeEach( async function () {
client = new Client({
network: 'regtest',
username: 'leeloo',
password: 'multipass',
beforeEach(async function () {
client = new Client({
network: 'regtest',
username: 'leeloo',
password: 'multipass',
port: 18443
})
})
it("Value of the latest transaction is correct", async function() {

it("Value of the latest transaction is correct", async function () {
let hashLatest = await client.getBestBlockHash()
console.assert(hashLatest!=null)
console.assert(hashLatest != null)
let block = await client.getBlockByHash(hashLatest)
let values = []
// expect a second transaction in the latest block (see dockerfile)
if (typeof block.tx[1] !== 'undefined') {
for (const vout of block.tx[1].vout) {
for (const vout of block.tx[1].vout) {
values.push(vout.value)
}
} else {
Expand All @@ -31,6 +31,6 @@ describe("retrieve transaction ins and outs", function() {
let retrievedInOuts = await retrieveTransactionInOut(txLatest)
expect(retrievedInOuts.out).to.deep.equal(values)
})

})

10 changes: 5 additions & 5 deletions tests/js/local-node.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const { expect } = require("chai");
const { expect } = require("chai")

describe("Have you read the tutorial?", function() {
describe("Have you read the tutorial?", function () {
let register = {}
beforeEach( async function () {
beforeEach(async function () {

})

it("Should validate", async function() {
it("Should validate", async function () {
expect(0).to.be.equal(0)
});
})

});

3 changes: 1 addition & 2 deletions tests/js/send-eth-transaction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ let {txid} = require("/jail/student/send-eth-transaction.js");

function isSha256(h) {
h = h.slice(2)
console.log(h)
const regex = /^[a-f0-9]{64}$/gi
return regex.test(h)
}
Expand All @@ -18,7 +17,7 @@ describe('Send transaction', function () {
});



// Prior version of the test using test.mjs
// // /*/ // ⚡

// setup = function (params) {
Expand Down
124 changes: 0 additions & 124 deletions tests/mjs/test.mjs

This file was deleted.

36 changes: 0 additions & 36 deletions tests/sol/namedFestival.test.js

This file was deleted.

0 comments on commit b9187e3

Please sign in to comment.