Skip to content

Commit a437313

Browse files
committed
use dune-project
1 parent ef91885 commit a437313

File tree

11 files changed

+160
-68
lines changed

11 files changed

+160
-68
lines changed

Diff for: bin/node.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ let load_filter w data =
3636
debug "Sent FilterLoad"
3737
;;
3838

39-
let get_data w invs =
40-
let msg = Message.GetData invs in
41-
let cs = Message.to_cstruct ~network:!network buf msg in
42-
write_cstruct2 w buf cs;
43-
debug "Sent GetData"
44-
;;
39+
(* let get_data w invs = *)
40+
(* let msg = Message.GetData invs in *)
41+
(* let cs = Message.to_cstruct ~network:!network buf msg in *)
42+
(* write_cstruct2 w buf cs; *)
43+
(* debug "Sent GetData" *)
44+
(* ;; *)
4545

4646
let process_error _w header = sexp ~level:`Error (MessageHeader.sexp_of_t header)
4747

Diff for: bitcoin-node.opam

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This file is generated by dune, edit dune-project instead
2+
opam-version: "2.0"
3+
synopsis: "Bitcoin node implementation with Async"
4+
description: ""
5+
maintainer: ["Vincent Bernardoff"]
6+
authors: ["Vincent Bernardoff <[email protected]>"]
7+
license: "LICENSE"
8+
tags: ["crypto" "bitcoin"]
9+
homepage: "https://github.com/vbmithr/ocaml-bitcoin"
10+
doc: "https://url/to/documentation"
11+
bug-reports: "https://github.com/vbmithr/ocaml-bitcoin/issues"
12+
depends: [
13+
"ocaml"
14+
"dune" {>= "3.16"}
15+
"bitcoin"
16+
"core"
17+
"async"
18+
"uri"
19+
"base58"
20+
"odoc" {with-doc}
21+
]
22+
build: [
23+
["dune" "subst"] {dev}
24+
[
25+
"dune"
26+
"build"
27+
"-p"
28+
name
29+
"-j"
30+
jobs
31+
"@install"
32+
"@runtest" {with-test}
33+
"@doc" {with-doc}
34+
]
35+
]
36+
dev-repo: "git+https://github.com/vbmithr/ocaml-bitcoin.git"

Diff for: bitcoin.opam

+39-35
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,47 @@
1+
# This file is generated by dune, edit dune-project instead
12
opam-version: "2.0"
2-
name: "bitcoin"
3-
authors: "Vincent Bernardoff <[email protected]>"
4-
maintainer: "Vincent Bernardoff <[email protected]>"
3+
synopsis: "Bitcoin library"
4+
description: ""
5+
maintainer: ["Vincent Bernardoff"]
6+
authors: ["Vincent Bernardoff <[email protected]>"]
7+
license: "LICENSE"
8+
tags: ["crypto" "bitcoin"]
59
homepage: "https://github.com/vbmithr/ocaml-bitcoin"
10+
doc: "https://url/to/documentation"
611
bug-reports: "https://github.com/vbmithr/ocaml-bitcoin/issues"
7-
dev-repo: "git+https://github.com/vbmithr/ocaml-bitcoin"
8-
doc: "https://vbmithr.github.io/ocaml-bitcoin/doc"
9-
build: [ "dune" "build" "-j" jobs "-p" name ]
10-
run-test: [ "dune" "runtest" "-j" jobs "-p" name ]
1112
depends: [
12-
"ocaml" {>= "4.08.0"}
13-
"dune" {>= "2.3.1"}
14-
"fmt" {>= "0.8.8"}
15-
"rresult" {>= "0.6.0"}
16-
"astring" {>= "0.8.3"}
17-
"ptime" {>= "0.8.5"}
18-
"base" {>= "v0.13.1"}
19-
"sexplib" {>= "v0.13.0"}
20-
"ppx_sexp_conv" {>= "v0.13.0"}
21-
"ocplib-endian" {>= "1.0"}
22-
"stdint" {>= "0.6.0"}
23-
"ipaddr" {>= "4.0.0"}
24-
"ipaddr-sexp" {>= "4.0.0"}
25-
"cstruct" {>= "5.1.1"}
26-
"cstruct-sexp" {>= "5.1.1"}
27-
"ppx_cstruct" {>= "5.1.1"}
28-
"digestif" {>= "0.8.0-1"}
29-
"hex" {>= "1.4.0"}
30-
"bitv" {>= "1.3"}
31-
"secp256k1-internal" {>= "0.1.0"}
13+
"ocaml"
14+
"dune" {>= "3.16"}
15+
"fmt"
16+
"cstruct"
17+
"cstruct-sexp"
18+
"sexplib"
19+
"rresult"
20+
"stdint"
21+
"ipaddr"
22+
"ipaddr-sexp"
23+
"ptime"
24+
"hex"
25+
"bitv"
3226
"murmur3"
27+
"digestif"
28+
"secp256k1-internal"
3329
"base58"
34-
"alcotest" {with-test & >= "1.1.0"}
30+
"alcotest" {with-test}
31+
"odoc" {with-doc}
3532
]
36-
pin-depends: [
37-
["murmur3.dev" "git+https://github.com/vbmithr/ocaml-murmur3.git"]
38-
["base58.dev" "git+https://github.com/vbmithr/ocaml-base58.git"]
33+
build: [
34+
["dune" "subst"] {dev}
35+
[
36+
"dune"
37+
"build"
38+
"-p"
39+
name
40+
"-j"
41+
jobs
42+
"@install"
43+
"@runtest" {with-test}
44+
"@doc" {with-doc}
45+
]
3946
]
40-
synopsis:"Bitcoin library for OCaml"
41-
description:"""This library implements Bitcoin protocol
42-
datastructures, script, etc."""
43-
47+
dev-repo: "git+https://github.com/vbmithr/ocaml-bitcoin.git"

Diff for: cstruct/dune

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
(name bitcoin_cstruct)
33
(public_name bitcoin.cstruct)
44
(preprocess (pps ppx_cstruct))
5-
(modules bitcoin_cstruct)
6-
(libraries ptime cstruct))
5+
(libraries
6+
ptime
7+
cstruct)
8+
)

Diff for: dune-project

+56-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,57 @@
1-
(lang dune 1.4)
1+
(lang dune 3.16)
2+
23
(name bitcoin)
4+
5+
(generate_opam_files true)
6+
7+
(source
8+
(github vbmithr/ocaml-bitcoin))
9+
10+
(authors "Vincent Bernardoff <[email protected]>")
11+
12+
(maintainers "Vincent Bernardoff")
13+
14+
(license LICENSE)
15+
16+
(documentation https://url/to/documentation)
17+
18+
(package
19+
(name bitcoin)
20+
(synopsis "Bitcoin library")
21+
(description "")
22+
(depends
23+
ocaml
24+
dune
25+
fmt
26+
cstruct
27+
cstruct-sexp
28+
sexplib
29+
rresult
30+
stdint
31+
ipaddr
32+
ipaddr-sexp
33+
ptime
34+
hex
35+
bitv
36+
murmur3
37+
digestif
38+
secp256k1-internal
39+
base58
40+
(alcotest :with-test)
41+
)
42+
(tags (crypto bitcoin)))
43+
44+
(package
45+
(name bitcoin-node)
46+
(synopsis "Bitcoin node implementation with Async")
47+
(description "")
48+
(depends
49+
ocaml
50+
dune
51+
bitcoin
52+
core
53+
async
54+
uri
55+
base58
56+
)
57+
(tags (crypto bitcoin)))

Diff for: lib/dune

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
sexplib
99
rresult
1010
bitcoin_cstruct
11-
astring
1211
stdint
1312
ocplib-endian
1413
ipaddr

Diff for: lib/p2p.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,6 @@ module Message : sig
239239

240240
type error = Invalid_checksum of MessageHeader.t
241241

242-
val of_cstruct : Cstruct.t -> (MessageHeader.t * t, error) Rresult.result * Cstruct.t
242+
val of_cstruct : Cstruct.t -> (MessageHeader.t * t, error) result * Cstruct.t
243243
val to_cstruct : network:Network.t -> Cstruct.t -> t -> Cstruct.t
244244
end

Diff for: lib/util.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ module Bitv = struct
371371
let len = String.length s in
372372
let bitv = Bitv.create (len * 8) false in
373373
for i = 0 to len - 1 do
374-
let v = EndianString.BigEndian.get_int8 s i in
374+
let v = String.get_int8 s i in
375375
for j = 0 to 7 do
376376
if v land (1 lsl j) <> 0 then Bitv.set bitv ((8 * i) + j) true
377377
done

Diff for: lib/wallet.ml

+1-2
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,9 @@ module KeyPath = struct
130130
let pp ppf t = Format.pp_print_string ppf (to_string t)
131131

132132
let write_be buf pos t =
133-
let open EndianBytes.BigEndian in
134133
let len =
135134
ListLabels.fold_left t ~init:0 ~f:(fun i v ->
136-
set_int32 buf (pos + (i * 4)) v;
135+
Bytes.set_int32_be buf (pos + (i * 4)) v;
137136
i + 1)
138137
in
139138
pos + (len * 4)

Diff for: test/dune

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
(test
22
(name test)
3-
(libraries bitcoin alcotest))
3+
(libraries
4+
bitcoin
5+
alcotest))

Diff for: test/test.ml

+13-18
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ let rawTx =
2020
"0100000002ba0eb35fa910ccd759ff46b5233663e96017e8dfaedd315407dc5be45d8c260f000000001976a9146ce472b3cfced15a7d50b6b0cd75a3b042554e8e88acfdffffff69c84956a9cc0ec5986091e1ab229e1a7ea6f4813beb367c01c8ccc708e160cc000000001976a9146ce472b3cfced15a7d50b6b0cd75a3b042554e8e88acfdffffff01a17c0100000000001976a914efd0919fc05311850a8382b9c7e80abcd347343288ac00000000"
2121
;;
2222

23-
let keyPath = "44'/1'/0'/0/0"
24-
2523
let rawPrevTxs =
2624
[ `Hex
2725
"010000000324c6fae955eae55c27639e5537d00e6ef11559c26f9c36c6770030b38702b19b0d0000006b483045022100c369493b6caa7016efd537eedce8d9e44fe14c345cd5edbb8bdca5545daf4cbe022053ac076f1c04f2f10f107f2890d5d95513547690b9a27d647d1c1ea68f6f3512012102f812962645e606a97728876d93324f030c1fe944d58466960104d810e8dc4945ffffffff24c6fae955eae55c27639e5537d00e6ef11559c26f9c36c6770030b38702b19b0a0000006b48304502210094f901df086a6499f24f678eef305e81eed11d730696cfa23cf1a9e2208ab98302205e628d259e2450d71d67ad54a58b0f58d6b643b70957c8a72e8df1293b2eb9be012102f812962645e606a97728876d93324f030c1fe944d58466960104d810e8dc4945ffffffff24c6fae955eae55c27639e5537d00e6ef11559c26f9c36c6770030b38702b19b0c0000006a47304402205c59502f9075f764dad17d59da9eb5429e969e2608ab579e3185f639dfda2eee0220614d2101e2c17612dc59a247f6f5cbdefcd7ea8f74654caa08b11f42873e586201210268a925507fd7e84295e172b3eea2f056c166ddc874fcda45864d872725094225ffffffff0150c30000000000001976a9146ce472b3cfced15a7d50b6b0cd75a3b042554e8e88ac00000000"
@@ -30,11 +28,6 @@ let rawPrevTxs =
3028
]
3129
;;
3230

33-
let testTx =
34-
`Hex
35-
"01000000017b1eabe0209b1fe794124575ef807057c77ada2138ae4fa8d6c4de0398a14f3f00000000494830450221008949f0cb400094ad2b5eb399d59d01c14d73d8fe6e96df1a7150deb388ab8935022079656090d7f6bac4c9a94e0aad311a4268e082a725f8aeae0573fb12ff866a5f01ffffffff01f0ca052a010000001976a914cbc20a7664f2f69e5355aa427045bc15e7c6c77288ac00000000"
36-
;;
37-
3831
let hex = testable Hex.pp ( = )
3932
let cstruct = testable Cstruct.hexdump_pp Cstruct.equal
4033

@@ -139,22 +132,24 @@ module TestTransaction = struct
139132
;;
140133
end
141134

142-
(* module Wallet = struct
143-
* let test_keyPath_of_string () =
144-
* let open Wallet.KeyPath in
145-
* let kp = of_string_exn "44'/1'/0'/0/0" in
146-
* assert_equal kp [to_hardened 44l; to_hardened 1l; to_hardened 0l; 0l; 0l]
147-
*
148-
* let runtest = [
149-
* "KeyPath.of_string", `Quick, test_keyPath_of_string ;
150-
* ]
151-
* end *)
135+
let kp_tst = testable (Fmt.list Fmt.int32) (List.equal Int32.equal)
136+
137+
module Wallet = struct
138+
let test_keyPath_of_string () =
139+
let open Wallet.KeyPath in
140+
let kp = of_string_exn "44'/1'/0'/0/0" in
141+
check kp_tst "wallet" kp [ to_hardened 44l; to_hardened 1l; to_hardened 0l; 0l; 0l ]
142+
;;
143+
144+
let runtest = [ test_case "KeyPath.of_string" `Quick test_keyPath_of_string ]
145+
end
152146

153147
let () =
154148
run
155149
"bitcoin"
156150
[ "Util", TestUtil.runtest
157151
; "Script", TestScript.runtest
158-
; "Transaction", TestTransaction.runtest (* "Wallet", Wallet.runtest ; *)
152+
; "Transaction", TestTransaction.runtest
153+
; "Wallet", Wallet.runtest
159154
]
160155
;;

0 commit comments

Comments
 (0)