Skip to content

Commit

Permalink
Merge pull request hyperledger-archives#13 from hadleym/wrap-init
Browse files Browse the repository at this point in the history
Wrap init
  • Loading branch information
glowkey authored Oct 10, 2017
2 parents 65b9261 + 1e89271 commit 4bc88c2
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cxs/ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def build(name, file = 'cxs/ci/ubuntu.dockerfile cxs/ci', customParams = '') {
return docker.build("$name-test", "--build-arg uid=${getUserUid()} -f $file")
}

node {
node('ubuntu') {
stage ('Checkout'){
checkout scm
}
Expand Down
1 change: 1 addition & 0 deletions cxs/libcxs/src/api/cxs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ mod tests {
assert_eq!(result,0);
}


#[test]
fn test_cxs_connection_create() {
let mut handle: u32 = 0;
Expand Down
8 changes: 8 additions & 0 deletions cxs/libcxs/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ mod tests {
assert_eq!(rc, error::SUCCESS.code_num);
}

#[test]
fn test_state_not_connected() {
let handle = build_connection("Whatever".to_owned());
let state = get_state(handle);
assert_eq!(state, CxsStateType::CxsStateInitialized as u32);
release(handle);
}

#[test]
fn test_connect() {
let handle = build_connection("test_connect".to_owned());
Expand Down
4 changes: 4 additions & 0 deletions cxs/wrappers/node/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ node_modules/
jspm_packages/

# Typescript v1 declaration files
<<<<<<< HEAD
typings/
=======

>>>>>>> origin/compile-ts

# Optional npm cache directory
.npm
Expand Down
9 changes: 9 additions & 0 deletions cxs/wrappers/node/src/api/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as posix from 'path'
import { CXSRuntime } from '../index'
import { CXSRuntimeConfig } from '../rustlib'

export function init_cxs (filename) {
const config = new CXSRuntimeConfig(null)
const rust = new CXSRuntime(config)
return rust.ffi.cxs_init(filename)
}
1 change: 1 addition & 0 deletions cxs/wrappers/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ export class CXSRuntime implements ICXSAcessType {
this.ffi = ffi.Library(libraryPath, FFIConfiguration)
}
}
export { init_cxs } from './api/init'
14 changes: 14 additions & 0 deletions cxs/wrappers/node/test/wrapper-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { expect } from 'chai'
import { describe, it } from 'mocha'
import { init_cxs } from '../src/api/init'

describe('cxs_init', () => {
it ('should return 0 when given a null argument', () => {
const result = init_cxs(null)
expect(result).to.equal(0)
})
it ('should return 1001 when given an invalid argument', () => {
const result = init_cxs('garbage')
expect(result).to.equal(1001)
})
})

0 comments on commit 4bc88c2

Please sign in to comment.