'use strict';

define(['util/protocol'], function(Protocol) {

  describe('Protocol format', function() {
    it('packs a message', function() {
        var request = Protocol.packMessage('test', {foo: 'bar'});
        expect(request.type).toBe('test');
        expect(request.body).toEqual({foo: 'bar'});
    });

    it('creates a coinjoin open message', function() {
        var request = Protocol.CoinJoinOpenMsg('id', 10000);
        expect(request.type).toBe('CoinJoinOpen');
        expect(request.body).toEqual({id: 'id', amount: 10000});
    });

    it('creates a coinjoin message', function() {
        var request = Protocol.CoinJoinMsg('id', "deadbeef");
        expect(request.type).toBe('CoinJoin');
        expect(request.body).toEqual({id: 'id', tx: "deadbeef"});
    });

    it('creates a coinjoin finish message', function() {
        var request = Protocol.CoinJoinFinishMsg('id');
        expect(request.type).toBe('CoinJoinFinish');
        expect(request.body).toEqual({id: 'id'});
    });

    it('creates a contact message', function() {
        var address = {mpk: 'mpk', stealth: 'stealth'};
        var identity = {
          name: 'Delirium',
          wallet: { getAddress: function(){ return address} }
        };
        var request = Protocol.ContactMsg(identity);
        expect(request.type).toBe('Contact');
        expect(request.body).toEqual({name: 'Delirium', stealth: 'stealth'});
    });

    it('creates a shout message', function() {
        var request = Protocol.ShoutMsg("foo");
        expect(request.type).toBe('Shout');
        expect(request.body).toEqual({text: "foo"});
    });

    it('creates a multisig announce message', function() {
        var request = Protocol.MultisigAnnounceMsg("deadbeef");
        expect(request.type).toBe('MultisigAnnounce');
        expect(request.body).toEqual({multisig: "deadbeef"});
    });

    it('creates a multisig proposal message', function() {
        var request = Protocol.MultisigProposalMsg("deadbeef");
        expect(request.type).toBe('MultisigProposal');
        expect(request.body).toEqual({proposal: "deadbeef"});
    });
  });
 
});

@@ -31,16 +31,33 @@
 rotocol'
+, 'bitcoinjs-lib'
 %5D, funct
@@ -68,16 +68,25 @@
 Protocol
+, Bitcoin
 ) %7B%0A%0A  d
@@ -2148,16 +2148,499 @@
 %0A    %7D);
+%0A%0A    it('creates a pubkey', function() %7B%0A        var request = Protocol.PublicKeyRequestMsg(%22deadbeef%22);%0A        expect(request.type).toBe('publicKeyRequest');%0A        expect(request.text).toEqual(%7B%22deadbeef%22:%7B%7D%7D);%0A    %7D);%0A%0A    it('creates a pubkey request', function() %7B%0A        var request = Protocol.PublicKeyMsg(%22deadbeef%22, Bitcoin.BigInteger(%2210%22));%0A        expect(request.type).toBe('publicKey');%0A        expect(request.text).toEqual(%7B%22deadbeef%22:%7Bmessage: 'Cg=='%7D%7D);%0A    %7D);%0A%0A
 %0A  %7D);%0A 

Add missing coverage for util/protocol.